NessLab(6167).c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. extern volatile uint16_t ADC1value[ADC1_CNT];
  15. void NessLab_Operate(uint8_t* data){
  16. uint8_t datatype = data[NessLab_MsgID0];
  17. switch(datatype){
  18. case NessLab_STATUS_REQ:
  19. ADC_Check();
  20. break;
  21. }
  22. NessLab_Frame_Set(data,12);
  23. Uart1_Data_Send(&data, 30);
  24. }
  25. void NessLab_Frame_Set(uint8_t* data,uint8_t size){
  26. data[NessLab_Header0] = 0x7E;
  27. data[NessLab_Header1] = 0x7E;
  28. data[NessLab_MsgID0] = NessLab_STATUS_RES;// ID
  29. data[NessLab_MsgSN0] = 0; // SEQ NUMBER
  30. data[NessLab_MsgSN1] = 0; // SEQ NUMBER
  31. data[NessLab_Reserve0] = 0; // NessLab_Reserve0
  32. data[NessLab_DataLength] = size; // Nesslab Size
  33. data[NessLab_Data_ADC0_H] = 12; // (uint8_t)((ADC1value & 0xFF00) >> 8);
  34. data[NessLab_Data_ADC0_L] = 34; // (uint8_t)(ADC1value & 0x00FF);
  35. data[NessLab_Data_ADC1_H] = 00;
  36. data[NessLab_Data_ADC1_L] = 00;
  37. data[DC_FAIL_ALARM] = 11;
  38. data[NessLab_DownLink_Status] = 22;
  39. data[NessLab_Over_Power_Alarm] = 33;
  40. data[NessLab_VSWR_ALARM] = 44;
  41. data[NessLab_Over_Input_Alarm] = 55;
  42. data[NessLab_Over_Temp_Alarm] = 66;
  43. data[NessLab_Temp_Monitor] = 77;
  44. data[NessLab_ALC_ALARM] = 88;
  45. data[NessLab_ChecksumVal] = NessLab_Checksum(0, 17);
  46. /* Exception Header Tail Checksum */
  47. data[NessLab_Tail0] = 0x7E;
  48. data[NessLab_Tail0] = 0x7E;
  49. }
  50. void NessLab_Status_Check(){
  51. //HAL_GPIO_ReadPin(, GPIO_Pin)
  52. }
  53. void NessLab_PAU_Enable(){
  54. HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_EN_GPIO_Port, PAU_EN_Pin));
  55. //HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_RESET_GPIO_Port, PAU_RESET_Pin));
  56. }
  57. void NessLab_GPIO_Operate(){
  58. NessLab_PAU_Enable();
  59. }