nbus_slave_broadcast.c 953 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "nbus_slave.h"
  2. #if MODULE_SLAVE == 1
  3. inline void setErrorResponse(nBus_TypeDef *nbus, uint8_t code){
  4. nbus->function_code.error = 1;
  5. nbus->tx_buffer[4] = code;
  6. nbus->tx_length += 1;
  7. }
  8. void nbus_slave_broadcast(nBus_TypeDef *nbus, nBusCommandType_t request_type){
  9. if(request_type == BROADCAST_SPECIFIC_SENSORS) {
  10. }
  11. if(request_type == BROADCAST_GLOBAL) {
  12. switch(nbus->function_code.function) {
  13. case CMD_START:
  14. {
  15. nbus->measure_active = MEASURE_RUNNING;
  16. nbus->interface->start();
  17. //HAL_GPIO_WritePin(nbus->periph->led->port, nbus->periph->led->pin, GPIO_PIN_SET);
  18. nbus->hw_platform->led_on();
  19. }
  20. break;
  21. case CMD_STOP:
  22. {
  23. nbus->measure_active = MEASURE_STOPPED;
  24. nbus->interface->stop();
  25. //HAL_GPIO_WritePin(nbus->periph->led->port, nbus->periph->led->pin, GPIO_PIN_RESET);
  26. nbus->hw_platform->led_off();
  27. }
  28. break;
  29. default:
  30. ; // nothing
  31. }
  32. }
  33. nbus->send_response = NO_RESPONSE;
  34. }
  35. #endif