A20_VOICE_example.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "VOICE.h"
  19. #include "cmsis_os2.h"
  20. #include "ohos_init.h"
  21. #define TASK_STACK_SIZE 1024 * 8
  22. #define TASK_PRIO 25
  23. static void ExampleTask(void)
  24. {
  25. BoardInit();
  26. while (1)
  27. {
  28. BeepStatusSet(ON);
  29. LedRed1StatusSet(ON);
  30. LedRed2StatusSet(ON);
  31. LedBlue1StatusSet(OFF);
  32. LedBlue2StatusSet(OFF);
  33. osDelay(50);
  34. BeepStatusSet(OFF);
  35. LedRed1StatusSet(OFF);
  36. LedRed2StatusSet(OFF);
  37. LedBlue1StatusSet(ON);
  38. LedBlue2StatusSet(ON);
  39. osDelay(150);
  40. }
  41. }
  42. static void ExampleEntry(void)
  43. {
  44. osThreadAttr_t attr;
  45. attr.name = "ExampleTask";
  46. attr.attr_bits = 0U;
  47. attr.cb_mem = NULL;
  48. attr.cb_size = 0U;
  49. attr.stack_mem = NULL;
  50. attr.stack_size = TASK_STACK_SIZE;
  51. attr.priority = TASK_PRIO;
  52. if (osThreadNew((osThreadFunc_t)ExampleTask, NULL, &attr) == NULL) {
  53. printf("Failed to create ExampleTask!\n");
  54. }
  55. }
  56. APP_FEATURE_INIT(ExampleEntry);