A24_GPS_example.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2020  Jinan Bosai Network Technology Co., Ltd.
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <unistd.h>
  18. #include "L76K.h"
  19. #include "cmsis_os2.h"
  20. #include "ohos_init.h"
  21. #define TASK_STACK_SIZE 1024 * 8
  22. #define TASK_PRIO 25
  23. // #define FLAGS_MSK1 0x00000001U
  24. // osEventFlagsId_t evt_id;
  25. // static void Beep_Alarm(char *arg)
  26. // {
  27. // (void)arg;
  28. // osEventFlagsSet(evt_id, FLAGS_MSK1);
  29. // printf("Beep_Alarm\n");
  30. // }
  31. static void ExampleTask(void)
  32. {
  33. L76Data data;
  34. BoardInit();
  35. LedWarnStatusSet(ON);
  36. BeepStatusSet(ON);
  37. while (1) {
  38. L76ReadData(&data);
  39. printf("\r\n******************************Longitude Value is %.5f\r\n", data.Longitude);
  40. printf("\r\n******************************Latitude Value is %.5f\r\n", data.Latitude);
  41. sleep(1);
  42. }
  43. }
  44. static void ExampleEntry(void)
  45. {
  46. osThreadAttr_t attr;
  47. attr.name = "ExampleTask";
  48. attr.attr_bits = 0U;
  49. attr.cb_mem = NULL;
  50. attr.cb_size = 0U;
  51. attr.stack_mem = NULL;
  52. attr.stack_size = TASK_STACK_SIZE;
  53. attr.priority = TASK_PRIO;
  54. if (osThreadNew((osThreadFunc_t)ExampleTask, NULL, &attr) == NULL) {
  55. printf("Failed to create ExampleTask!\n");
  56. }
  57. }
  58. APP_FEATURE_INIT(ExampleEntry);