NessLab(4175).c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * NessLab.c
  3. *
  4. * Created on: Aug 3, 2020
  5. * Author: parkyj
  6. */
  7. #include "main.h"
  8. #include "NessLab.h"
  9. #include "adc.h"
  10. #include "crc.h"
  11. //extern uint8_t NessLab_Checksum(uint8_t* data,uint8_t size);
  12. Nesslab_Prot Currstatus;
  13. uint8_t data_Tx[50] = {0,};
  14. void NessLab_Operate(uint8_t* data){
  15. uint8_t datatype = data[NessLab_MsgID0];
  16. switch(datatype){
  17. case NessLab_STATUS_REQ:
  18. ADC_Check();
  19. break;
  20. }
  21. Uart1_Data_Send(&Currstatus, 30);
  22. }
  23. void NessLab_Frame_Set(uint8_t* data,uint8_t size){
  24. data[NessLab_Header0] = 0x7E;
  25. data[NessLab_Header1] = 0x7E;
  26. data[NessLab_MsgID0] = NessLab_STATUS_RES;// ID
  27. data[NessLab_MsgSN0] = 0; // SEQ NUMBER
  28. data[NessLab_MsgSN1] = 0; // SEQ NUMBER
  29. data[NessLab_Reserve0] = 0; // NessLab_Reserve0
  30. data[NessLab_Reserve0] = size; // Nesslab Size
  31. /* Exception Header Tail Checksum */
  32. Currstatus.Checksum = NessLab_Checksum(0, 17);
  33. Currstatus.Tail0 = 0x7E;
  34. Currstatus.Tail1 = 0x7E;
  35. }
  36. void NessLab_Status_Check(){
  37. //HAL_GPIO_ReadPin(, GPIO_Pin)
  38. }
  39. void NessLab_PAU_Enable(){
  40. HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_EN_GPIO_Port, PAU_EN_Pin));
  41. //HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_RESET_GPIO_Port, PAU_RESET_Pin));
  42. }
  43. void NessLab_GPIO_Operate(){
  44. NessLab_PAU_Enable();
  45. }