A01_DOOR_example.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent 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 "DOOR.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. // ST02D_Init();
  34. // Button_Left_Read_Data(Beep_Alarm);
  35. // Button_Right_Read_Data(Beep_Alarm);
  36. // while (1)
  37. // {
  38. // osEventFlagsWait(evt_id, FLAGS_MSK1, osFlagsWaitAny, osWaitForever);
  39. // BeepStatusSet(ON);
  40. // LedWarnStatusSet(ON);
  41. // osDelay(300);
  42. // BeepStatusSet(OFF);
  43. // LedWarnStatusSet(OFF);
  44. // }
  45. BoardInit();
  46. // Button_Left_Read_Data(Beep_Alarm);
  47. // Button_Right_Read_Data(Beep_Alarm);
  48. while (1)
  49. {
  50. if(Door_Read_Data() == 0)
  51. {
  52. BeepStatusSet(ON);
  53. LedWarnStatusSet(ON);
  54. LedSafeStatusSet(OFF);
  55. }
  56. else
  57. {
  58. BeepStatusSet(OFF);
  59. LedWarnStatusSet(OFF);
  60. LedSafeStatusSet(ON);
  61. }
  62. sleep(1);
  63. }
  64. }
  65. static void ExampleEntry(void)
  66. {
  67. osThreadAttr_t attr;
  68. attr.name = "ExampleTask";
  69. attr.attr_bits = 0U;
  70. attr.cb_mem = NULL;
  71. attr.cb_size = 0U;
  72. attr.stack_mem = NULL;
  73. attr.stack_size = TASK_STACK_SIZE;
  74. attr.priority = TASK_PRIO;
  75. if (osThreadNew((osThreadFunc_t)ExampleTask, NULL, &attr) == NULL) {
  76. printf("Failed to create ExampleTask!\n");
  77. }
  78. }
  79. APP_FEATURE_INIT(ExampleEntry);