Communication.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include "Comunication.h"
  2. #include "confOrdi.h"
  3. #include "Actuator.h"
  4. #include <stdint.h>
  5. uint8_t Com_dispactch(uint8_t* mes){
  6. switch(mes[0]|MASKMES){
  7. case (STATUS):
  8. Com_Status(mes);
  9. return 0;
  10. case (READACTUA):
  11. Com_ReadActuator();
  12. return 0;
  13. case (WRITEACTUA):
  14. Com_WriteActuator(mes);
  15. return 0;
  16. case (READVENTIL):
  17. Com_ReadVentil();
  18. return 0;
  19. case (WRITEVENTIL):
  20. Com_WriteVentil(mes);
  21. return 0;
  22. case (ACKERREUR):
  23. // a faire
  24. return 0;
  25. case (RESERVE2)
  26. // a faire
  27. return 0;
  28. default:
  29. return -1;//erreur
  30. }
  31. }
  32. uint8_t Com_WriteActuator(uint8_t* mes){
  33. if(mes[0]&MASKECUMEUR == 0)
  34. Actuator_stop(ECUMEUR);
  35. else
  36. Actuator_start(ECUMEUR);
  37. if(mes[0]&MASKBRASSAGE1 == 0)
  38. Actuator_stop(BRASSAGE1);
  39. else
  40. Actuator_start(BRASSAGE1);
  41. if(mes[0]&MASKBRASSAGE2 == 0)
  42. Actuator_stop(BRASSAGE2);
  43. else
  44. Actuator_start(BRASSAGE2);
  45. if(mes[0]&MASKREMONTER == 0)
  46. Actuator_stop(REMONTER);
  47. else
  48. Actuator_start(REMONTER);
  49. if(mes[1]&MASKCHAUFFAGE == 0)
  50. Actuator_stop(CHAUFFAGE);
  51. else
  52. Actuator_start(CHAUFFAGE);
  53. if(mes[1]&MASKOSMOLATEUR == 1)
  54. Actuator_start(OSMOLATEUR);
  55. HAL_TIM_Base_Start_IT(&htim4);
  56. if(mes[0]&MASKOSMOLATEUR == 1)
  57. Actuator_start(OSMOLATEUR2);
  58. Com_Read();
  59. }
  60. uint8_t Com_ReadActuator(){
  61. }
  62. uint8_t Com_Status(uint8_t* mes){
  63. }