hal_laser.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /********************** Í·Îļþ *************************/
  2. #include "usr.h"
  3. #include "hal_laser.h"
  4. #include "system.h"
  5. #include "bsp_time.h"
  6. #include "hal_flash.h"
  7. #include "hal_ble_client.h"
  8. #include "hal_ble_host.h"
  9. #if LASER_ENABLE
  10. static uint8_t isOrganFlag = 0;
  11. static uint8_t OrganEnable = 0;
  12. void hal_laser_Enable(uint8_t organOnOff)
  13. {
  14. isOrganFlag = organOnOff;
  15. }
  16. uint8_t hal_laser_Getstate(void)
  17. {
  18. return OrganEnable;
  19. }
  20. static void hal_laser_process(void)
  21. {
  22. static uint8_t state = 0;
  23. static uint32_t tim =0;
  24. if(TIME_GetTicks()-tim>=200){tim = TIME_GetTicks();
  25. switch(state){
  26. case 0:
  27. if(1 == isOrganFlag){
  28. state =1;
  29. OrganEnable = 1;
  30. if(0 == mFlash.isHost)BLE_Client_Tx_Send(0,BLE_CLient_T_SET_ORGAN,&OrganEnable,1);
  31. }
  32. break;
  33. case 1:
  34. if(0 == isOrganFlag){
  35. state =0;
  36. OrganEnable = 0;
  37. if(0 == mFlash.isHost)BLE_Client_Tx_Send(0,BLE_CLient_T_SET_ORGAN,&OrganEnable,1);
  38. }
  39. break;
  40. }
  41. }
  42. }
  43. void hal_laser_init(void){
  44. Process_Start(200,"hal_laser_process",hal_laser_process);
  45. }
  46. #endif