// Auto-generated template file: command_SENSOR_MAXVALUE_RESET.tpl.c // Generation timestamp: 2021-06-17 18:31:59.933877 #include "../typedefs.h" #include "../communication.h" #include "../hardware.h" #include "../spurious.h" // NOT INCLUDED IN GENERATED CODE #include "../adcreader.h" // NOT INCLUDED IN GENERATED CODE err_t command_SENSOR_MAXVALUE_RESET(void) { // Command: SENSOR_MAXVALUE_RESET // Description: Reset the max value of one sensor (or all sensors) // // Request code: CMDCODE_SENSOR_MAXVALUE_RESET_REQ // Response code: CMDCODE_SENSOR_MAXVALUE_RESET_REQ // Request payload (length in bytes is 1): // field #0 (1 byte) [type: enum_variable_number_all_t] : VARIABLE_NUMBER_ALL (Variable number) // Response payload (length in bytes is 0): // Auto-generated section: request payload fields reading enum_variable_number_all_t req_variable_number_all = (enum_variable_number_all_t)communication_request_payload_retrieve_uint8_t(); // checking range for enum field req_variable_number_all if((uint8_t)req_variable_number_all < (uint8_t)enum_variable_number_all_t_min) return ERR_RANGE; if((uint8_t)req_variable_number_all > (uint8_t)enum_variable_number_all_t_max) return ERR_RANGE; // End of auto-generated section // USER CODE HERE // TODO CHECK command_SENSOR_MAXVALUE_RESET for(uint8_t variable_number = enum_variable_number_t_min; variable_number <= enum_variable_number_t_max; variable_number++) { if((req_variable_number_all == VARIABLE_NUMBER_ALL_ALL_VARIABLES) | (req_variable_number_all == variable_number)) { if(variable_is_analog_by_enum(variable_number)) { analog_variable_t* p_variable = analog_variable_get_pointer_by_enum(variable_number); INTERRUPT_GlobalInterruptDisable(); p_variable->value_max = 0; INTERRUPT_GlobalInterruptEnable(); }else{ digital_variable_t* p_variable = digital_variable_get_pointer_by_enum(variable_number); INTERRUPT_GlobalInterruptDisable(); p_variable->value_max = 0; INTERRUPT_GlobalInterruptEnable(); } } } // Auto-generated section: response payload fields writing communication_response_payload_appender_reset(); return NOERR; // End of auto-generated section }