bsp_gpio.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /********************** 头文件 *************************/
  2. #include "bsp_gpio.h"
  3. /********************** 变量区 *************************/
  4. /********************** 函数声明区 *************************/
  5. void LED_AllOff(void)
  6. {
  7. nrf_gpio_pin_write(LED_RUN,1);
  8. nrf_gpio_pin_write(LED_R,1);
  9. nrf_gpio_pin_write(LED_G,1);
  10. nrf_gpio_pin_write(LED_B,1);
  11. }
  12. void LED_process(void)
  13. {
  14. #if DEBUG_LEDRUN
  15. static uint32_t tim=0;
  16. if(TIME_GetTicks()-tim>=100){ tim = TIME_GetTicks();
  17. uint32_t err = ERR_Get();
  18. if(err==0) nrf_gpio_pin_toggle(LED_RUN);
  19. }
  20. #endif
  21. }
  22. void LED_Init(void)
  23. { //TF_DET_PIN
  24. nrf_gpio_cfg_output(LED_RUN); nrf_gpio_pin_write(LED_RUN,1);
  25. nrf_gpio_cfg_output(LED_R); nrf_gpio_pin_write(LED_R,1);
  26. nrf_gpio_cfg_output(LED_G); nrf_gpio_pin_write(LED_G,1);
  27. nrf_gpio_cfg_output(LED_B); nrf_gpio_pin_write(LED_B,1);
  28. nrf_gpio_cfg_input(TF_DET_PIN,NRF_GPIO_PIN_PULLUP);
  29. }
  30. static uint32_t mt_time = 0;
  31. void gpio_mt_run(uint32_t tim)
  32. {
  33. mt_time = tim;
  34. nrf_gpio_pin_write(MT_EN,1);
  35. }
  36. void gpio_mt_process(void* T)
  37. {
  38. if(mt_time>0){
  39. mt_time--;
  40. if(mt_time==0)
  41. nrf_gpio_pin_write(MT_EN,0);
  42. }
  43. }
  44. void MT_Init(void)
  45. {
  46. nrf_gpio_cfg_output(MT_EN); nrf_gpio_pin_write(MT_EN,0);
  47. gpio_mt_run(10);
  48. TIME_Regist(gpio_mt_process);
  49. }
  50. void GPIO_init(void)
  51. {
  52. LED_Init();
  53. MT_Init();
  54. }