diff --git a/fw/.cproject b/fw/.cproject index 51ffe1b..3f03a16 100644 --- a/fw/.cproject +++ b/fw/.cproject @@ -29,6 +29,12 @@ + + + + + + @@ -52,6 +58,10 @@ + + + + @@ -83,6 +93,10 @@ + + + + @@ -104,21 +118,21 @@ - - - - - + + + + + - + - + - - - + + + @@ -133,7 +147,7 @@ - + @@ -142,11 +156,11 @@ - - + + - + @@ -187,6 +201,13 @@ - + + + + + + + + \ No newline at end of file diff --git a/fw/Core/Inc/config.h b/fw/Core/Inc/config.h index bb357d8..9f9b66c 100644 --- a/fw/Core/Inc/config.h +++ b/fw/Core/Inc/config.h @@ -25,6 +25,7 @@ config_read(&config); #include "stdint.h" #include "stm32l0xx.h" +#include "ltr329.h" /* DESCRIPTION OF THE DATA STRUCTURE */ /* * Data are divided into two groups: @@ -120,15 +121,11 @@ extern const uint8_t config_baudrates_length; typedef struct { - /* LED CONFIG */ - uint8_t led_on; - uint16_t led_brightness; - uint8_t led_smooth; - uint16_t led_co2_alert_limit1; - uint16_t led_co2_alert_limit2; - - /* SCD4x Temperature sensor offset */ - int16_t scd4x_t_offset; + /* LTR329 CONFIG */ + ltr329_gain_t ltr329_gain; + ltr329_als_mode_t ltr329_mode; + ltr329_integration_time_t ltr329_integ_time; + ltr329_measurement_rate_t ltr329_meas_rate; /* MODBUS CONFIG */ uint16_t modbus_addr; @@ -136,6 +133,7 @@ typedef struct } config_t; + /* const uint32_t baudrates [] = {19200, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 76800, 115200}; */ int8_t config_read(config_t *config); diff --git a/fw/Core/Inc/crc8.h b/fw/Core/Inc/crc8.h deleted file mode 100644 index 6820352..0000000 --- a/fw/Core/Inc/crc8.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * crc.h - * - * Created on: Jun 9, 2021 - * Author: user - */ - -#ifndef INC_CRC8_H_ -#define INC_CRC8_H_ - -#include "stdint.h" - -/* - * Definitions & macros - */ - -#define CRC8_POLYNOMIAL ((uint8_t)0x31) -#define CRC8_INIT ((uint8_t)0xFF) - -uint8_t crc8_calculate(const uint8_t *data, uint16_t count); - -#endif /* INC_CRC8_H_ */ diff --git a/fw/Core/Inc/ltr329.h b/fw/Core/Inc/ltr329.h deleted file mode 100644 index 7294a2a..0000000 --- a/fw/Core/Inc/ltr329.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * ltr329.h - * - * Created on: May 22, 2022 - * Author: david - */ - -#ifndef INC_LTR329_H_ -#define INC_LTR329_H_ - -#include "stdint.h" -#include "stm32l0xx_ll_i2c.h" -#include "stm32l0xx_ll_utils.h" -#include "i2c.h" - -#define LTR329_I2C_ADDRESS 0x29 - -/* - * Return values - */ - -#define LTR329_OK 0 -#define LTR329_ERROR -1 // generic error - -/* LTR-329ALS-01 Registers */ -/* Datasheet: https://optoelectronics.liteon.com/upload/download/DS86-2014-0006/LTR-329ALS-01_DS_V1.pdf */ -typedef enum -{ - LTR329_ALS_CONTR = 0x80, /* RW */ - LTR329_ALS_MEAS_RATE = 0x85, /* RW */ - LTR329_PART_ID = 0x86, /* R */ - LTR329_MANUFAC_ID = 0x87, /* R */ - LTR329_ALS_DATA_CH1_0 = 0x88, /* R */ - LTR329_ALS_DATA_CH1_1 = 0x89, /* R */ - LTR329_ALS_DATA_CH0_0 = 0x8A, /* R */ - LTR329_ALS_DATA_CH0_1 = 0x8B, /* R */ - LTR329_ALS_STATUS = 0x8C /* R */ -} ltr329_cmd_t; - -/* Bit masks for ALS Mode */ -typedef enum -{ - LTR329_MODE_STAND_BY = 0b00000000, /* DEFAULT */ - LTR329_MODE_ACTIVE = 0b00000001 -} ltr329_als_mode_t; - -/* Bit masks for Gain settings */ -typedef enum -{ - LTR329_GAIN_1X = 0b00000000, /* DEFAULT */ - LTR329_GAIN_2X = 0b00000100, - LTR329_GAIN_4X = 0b00001000, - LTR329_GAIN_8X = 0b00001100, - LTR329_GAIN_48X = 0b00011000, - LTR329_GAIN_96X = 0b00011100, - LTR329_GAIN_RESERVED1 = 0b00010000, - LTR329_GAIN_RESERVED2 = 0b00010100 -} ltr329_gain_t; - -/* Bit masks for Integration Time settings */ -typedef enum -{ - LTR329_INTEGRATION_50MS = 0b00001000, - LTR329_INTEGRATION_100MS = 0b00000000, /* DEFAULT */ - LTR329_INTEGRATION_150MS = 0b00100000, - LTR329_INTEGRATION_200MS = 0b00010000, - LTR329_INTEGRATION_250MS = 0b00101000, - LTR329_INTEGRATION_300MS = 0b00110000, - LTR329_INTEGRATION_350MS = 0b00111000, - LTR329_INTEGRATION_400MS = 0b00011000 -} ltr329_integration_time_t; - -/* Bit masks for Measurement Rate settings */ -typedef enum -{ - LTR329_MEAS_RATE_50MS = 0b00000000, - LTR329_MEAS_RATE_100MS = 0b00000001, - LTR329_MEAS_RATE_200MS = 0b00000010, - LTR329_MEAS_RATE_500MS = 0b00000011, /* DEFAULT */ - LTR329_MEAS_RATE_1000MS = 0b00000100, - LTR329_MEAS_RATE_2000MS = 0b00000111 -} ltr329_measurement_rate_t; - -static int8_t ltr329_read_register (ltr329_cmd_t register_addr, uint8_t *register_data ); -static int8_t ltr329_write_register (ltr329_cmd_t register_addr, uint8_t register_data); -int8_t ltr329_write_settings (ltr329_gain_t gain, ltr329_als_mode_t mode, ltr329_integration_time_t integ_time, ltr329_measurement_rate_t meas_rate); -int8_t ltr329_read_settings (ltr329_gain_t *gain, ltr329_als_mode_t *mode, ltr329_integration_time_t *integ_time, ltr329_measurement_rate_t *meas_rate); -int8_t ltr329_sw_reset( void ); -int8_t ltr329_measure (uint16_t *data_ch0, uint16_t *data_ch1); -int8_t ltr329_read_status_register(uint8_t *data_valid, uint8_t *new_data, ltr329_gain_t *gain); -int8_t ltr329_read_device_info (uint8_t *manufacturer_id, uint8_t *part_id); - -#endif /* INC_LTR329_H_ */ diff --git a/fw/Core/Inc/modbus.h b/fw/Core/Inc/modbus.h deleted file mode 100644 index ff01f65..0000000 --- a/fw/Core/Inc/modbus.h +++ /dev/null @@ -1,231 +0,0 @@ -/* - * modbus.h - * - * Created on: Jul 18, 2021 - * Author: user - * - * Modbus slave RTU library (does NOT support ASCII and TCP) - * - * Useful links: - * https://www.picotech.com/library/oscilloscopes/modbus-serial-protocol-decoding - * https://ipc2u.com/articles/knowledge-base/modbus-rtu-made-simple-with-detailed-descriptions-and-examples/ - * https://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf - * https://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf - * - * Note that byte order is big endian. - * - * USAGE: - * - * 1) Implement functions modbus_callback_function() and modbus_uart_transmit_function() - * - modbus_uart_transmit_function() sends data via UART - * - modbus_callback_function() does the real work: read sensors, set outputs... - * note that when filling buffers (e.g. input_registers[]) user must - * ensure that all data is big-endian - * These functions are implementation-specific. - * 2) Set device address (variable modbus_device_address); you can do this either - * - setting modbus_device_address directly (modbus.h needs to be included, duh) - * - using modbus_set_device_address(uint8_t address) function - * Or you can leave address as-is (MODBUS_DEFAULT_SLAVE_ADDRESS) and set it via - * Modbus during runtime - * 3) Call modbus_process_msg() after message reception; you need to observe Modbus RTU timing: - * - pauses between chars in frame are less or equal to 1.5 char - * - pauses between frames are at least 3.5 chars (of silence) - * For more information see section 2.5.1.1 (MODBUS Message RTU Framing) - * in "MODBUS over Serial Line: Specification and Implementation Guide" - * - */ - -#ifndef SRC_MODBUS_H_ -#define SRC_MODBUS_H_ - -#include "stdint.h" -#include "stddef.h" -#include "string.h" - -/* - * Defines & macros - */ - -#define MODBUS_BROADCAST_ADDR 0 -#define MODBUS_DEFAULT_SLAVE_ADDRESS 247 /* 255 may be used for bridge device */ -/* minimal frame length is 4 bytes: 1 B slave address, 1 B function code, 2 B CRC */ -#define MODBUS_MINIMAL_FRAME_LEN 4 -#define MODBUS_MINIMAL_READWRITE_LEN 4 -#define MODBUS_MINIMAL_WRITE_MULTIPLE_LEN 5 -#define MODBUS_READ_DEVICE_ID_REQUEST_LEN 4 -#define MODBUS_READ_DEVICE_ID_RESPONSE_HEADER_LEN 4 -#define MODBUS_READ_DEVICE_ID_RESPONSE_OFFSET 3 -#define MODBUS_MAX_RTU_FRAME_SIZE 256 -#define MODBUS_BUFFER_SIZE MODBUS_MAX_RTU_FRAME_SIZE /* alias */ -#define MODBUS_ERROR_FLAG 0x80 -#define MODBUS_MAX_REGISTERS 125 -/* read device id constants */ -#define MODBUS_MEI 0x0E -#define MODBUS_DEVICE_ID_INDIVIDUAL_ACCESS_FLAG 0x80 -#define MODBUS_MORE_FOLLOWS 0xFF -#define MODBUS_NO_MORE_FOLLOWS 0x00 -#define MODBUS_BASIC_OBJECT_COUNT 3 -#define MODBUS_REGULAR_OBJECT_COUNT 7 - -/* - * Return values - */ - -#define MODBUS_OK 0 -#define MODBUS_ERROR -1 // generic error -#define MODBUS_ERROR_CRC -2 // checksum failed -#define MODBUS_ERROR_FRAME_INVALID -3 // invalid frame format / length -#define MODBUS_ERROR_OUT_OF_BOUNDS -4 // requested register is out of bounds -#define MODBUS_ERROR_FUNCTION_NOT_IMPLEMENTED -5 // function not implemented in callback -#define MODBUS_ERROR_REGISTER_NOT_IMPLEMENTED -6 // register not implemented in callback -#define MODBUS_ERROR_DEVICE_ID_NOT_IMPLEMENTED -7 - -/* - * Data types - */ - -/* Public functions codes (Modbus Application protocol specification, section 5.1) */ -typedef enum { - /* single bit access functions */ - MODBUS_READ_COILS = 1, - MODBUS_READ_DO = 1, // alias - MODBUS_READ_DISCRETE_INPUTS = 2, - MODBUS_READ_DI = 2, // alias - MODBUS_WRITE_SINGLE_COIL = 5, - MODBUS_WRITE_SINGLE_DO = 5, // alias - MODBUS_WRITE_MULTIPLE_COILS = 15, - MODBUS_WRITE_MULTIPLE_DO = 15, // alias - /* 16-bit access functions */ - MODBUS_READ_HOLDING_REGISTERS = 3, - MODBUS_READ_AO = 3, // alias - MODBUS_READ_INPUT_REGISTERS = 4, - MODBUS_READ_AI = 4, // alias - MODBUS_WRITE_SINGLE_REGISTER = 6, - MODBUS_WRITE_SINGLE_AO = 6, // alias - MODBUS_WRITE_MULTIPLE_REGISTERS = 16, - MODBUS_WRITE_MULTIPLE_AO = 16, // alias - MODBUS_MASK_WRITE_REGISTER = 22, - MODBUS_READ_WRITE_MULTIPLE_REGISTERS = 23, - MODBUS_READ_FIFO_QUEUE = 24, - /* file record access */ - MODBUS_READ_FILE_RECORD = 20, - MODBUS_WRITE_FILE_RECORD = 21, - /* diagnostics */ - MODBUS_READ_EXCEPTION_STATUS = 7, - MODBUS_DIAGNOSTIC = 8, /* sub codes: 00-18,20 */ - MODBUS_GET_COM_EVENT_COUNTER = 11, - MODBUS_GET_COM_EVENT_LOG = 12, - MODBUS_REPORT_SLAVE_ID = 17, - MODBUS_READ_DEVICE_IDENTIFICATION = 43, /* sub codes: 14 */ -} modbus_function_code_t; - -typedef enum { - MODBUS_EXCEPTION_ILLEGAL_FUNCTION = 1, - MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS = 2, - MODBUS_EXCEPTION_ILLEGAL_REGISTER_QUANTITY = 2, - MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE = 3, - MODBUS_EXCEPTION_SLAVE_DEVICE_FAILURE = 4, - MODBUS_EXCEPTION_ACKNOWLEDGE = 5, - MODBUS_EXCEPTION_SLAVE_DEVICE_BUSY = 6, - MODBUS_EXCEPTION_MEMORY_PARITY_ERROR = 8, - MODBUS_EXCEPTION_GATEWAY_PATH_UNAVAILABLE = 10, - MODBUS_EXCEPTION_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND = 11, - MODBUS_EXCEPTION_ILLEGAL_DEVICE_ID_CODE = 3 -} modbus_exception_code_t; - -typedef struct { - modbus_function_code_t function_code : 8; - uint16_t register_address; // e.g. first register of A0: 0 - uint16_t register_number; // e.g. first register of A0: 40001 - uint8_t register_count; // number of registers to be read/written - - modbus_exception_code_t exception; - - uint8_t broadcast; // 1 if broadcast, 0 otherwise - - union { - uint8_t buffer8b[MODBUS_MAX_RTU_FRAME_SIZE]; - uint16_t buffer16b[MODBUS_MAX_RTU_FRAME_SIZE/2]; - uint16_t input_registers[MODBUS_MAX_REGISTERS]; - uint16_t holding_registers[MODBUS_MAX_REGISTERS]; - int16_t input_registers_signed[MODBUS_MAX_REGISTERS]; - int16_t holding_registers_signed[MODBUS_MAX_REGISTERS]; - }; - - /* process device id */ - uint8_t read_device_id_code; - uint8_t object_id; -} modbus_transaction_t; - -typedef enum { - MODBUS_DO_START_NUMBER = 1, // Discrete output coils - MODBUS_DO_END_NUMBER = 9999, - MODBUS_DI_START_NUMBER = 10001, // Discrete input contacts - MODBUS_DI_END_NUMBER = 19999, - MODBUS_AI_START_NUMBER = 30001, // Analog input registers - MODBUS_AI_END_NUMBER = 39999, - MODBUS_AO_START_NUMBER = 40001, // Analog output (holding registers) - MODBUS_AO_END_NUMBER = 49999 -} modbus_register_number_t; - -typedef enum { - MODBUS_CONFORMITY_BASIC = 1, - MODBUS_CONFORMITY_REGULAR = 2, - MODBUS_CONFORMITY_EXTENDED = 3, - MODBUS_INDIVIDUAL_ACCESS = 4 /* not actually part of conformity, but I'll keep it here anyway */ -} modbus_conformity_level_t; - -/* Device ID datatypes */ -#define MODBUS_DEVICE_ID_OBJECT_NUM 7 -typedef struct { - union { - struct { - /* Basic category (mandatory part) */ - char *VendorName; - char *ProductCode; - char *MajorMinorRevision; - /* Regular category (optional part) */ - char *VendorUrl; - char *ProductName; - char *ModelName; - char *UserApplicationName; - /* Extended category (optional part) */ - // Nothing here yet! - } object_name; - char *object_id[MODBUS_DEVICE_ID_OBJECT_NUM]; - }; - uint8_t conformity_level; -} modbus_device_id_t; - -/* - * Global variables - */ - -/* device address: declared in modbus.c */ -extern uint8_t modbus_slave_address; - -/* shared modbus buffer; defined in modbus.c; may be used elsewhere in code */ -extern uint8_t modbus_buffer[]; - -/* modbus device id struct */ -extern modbus_device_id_t *modbus_device_id; - -/* - * Function prototypes - */ - -/* process message: should be called in when modbus message was received (e.g. in main.c) - * modbus_process_msg() may call following functions: - * - modbus_callback_function() if data readout is requested - * - modbus_uart_transmit_function() if response is required - * Both functions have to be implemented by user. - */ -int8_t modbus_slave_process_msg(const uint8_t *buffer, int len); -int8_t modbus_slave_init_device_id(modbus_device_id_t *device_id); -int8_t modbus_slave_set_address(uint8_t address); -/* modbus callback function type - should be implemented by user (e.g. in main.c) */ -int8_t modbus_slave_callback(modbus_transaction_t *transaction); -/* UART transmit function type - should be implemented by user (e.g. in main.c) */ -int8_t modbus_transmit_function(uint8_t *buffer, uint16_t data_len); - -#endif /* SRC_MODBUS_H_ */ diff --git a/fw/Core/Inc/sht4x.h b/fw/Core/Inc/sht4x.h deleted file mode 100644 index 36c4351..0000000 --- a/fw/Core/Inc/sht4x.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * sht4x.h - * - * Created on: Jun 8, 2021 - * Author: user - */ - -#ifndef INC_SHT4X_H_ -#define INC_SHT4X_H_ - -#include "stdint.h" -#include "stm32l0xx_ll_i2c.h" -#include "stm32l0xx_ll_utils.h" -#include "i2c.h" -#include "crc8.h" - -/* - * Defines & macros - */ - -#define SHT4X_I2C_ADDRESS 0x44 - -/* - * Return values - */ - -#define SHT4X_OK 0 -#define SHT4X_ERROR -1 // generic error -#define SHT4X_CRC8_ERROR -2 // checksum failed - -/* - * Data types - */ - -typedef enum { - SHT4X_START_MEAS_HIGH_PRECISION = 0xFD, - SHT4X_START_MEAS_MEDIUM_PRECISION = 0xF6, - SHT4X_START_MEAS_LOW_PRECISION = 0xE0, - SHT4X_READ_SERIAL = 0x89, - SHT4X_SOFT_RESET = 0x94, - SHT4X_HEATER_200_mW_1_s = 0x39, - SHT4X_HEATER_200_mW_01_s = 0x32, - SHT4X_HEATER_110_mW_1_s = 0x2F, - SHT4X_HEATER_110_mW_01_s = 0x24, - SHT4X_HEATER_20_mW_1_s = 0x1E, - SHT4X_HEATER_20_mW_01_s = 0x15 -} sht4x_cmd_t; - -/* - * Function prototypes - */ - -int8_t sht4x_send_cmd(sht4x_cmd_t cmd); -int8_t sht4x_read_data(uint8_t *buffer, int len); -int8_t sht4x_measure(int16_t *temperature, uint16_t *relative_humidity); - -#endif /* INC_SHT4X_H_ */ diff --git a/fw/Core/Src/config.c b/fw/Core/Src/config.c index 08f6112..3dc2436 100644 --- a/fw/Core/Src/config.c +++ b/fw/Core/Src/config.c @@ -44,23 +44,11 @@ int8_t config_read(config_t *config) { config->modbus_addr = *(uint16_t *) (CONFIG_EEPROM_ADDR_MODBUS_ADDR); config->baudrate_index = *(uint16_t *) (CONFIG_EEPROM_ADDR_BAUDRATE_INDEX); - config->led_on = *(uint16_t *) (CONFIG_EEPROM_ADDR_LED_ON); - config->led_brightness = *(uint16_t *) (CONFIG_EEPROM_ADDR_LED_BRIGHTNESS); - config->led_smooth = *(uint16_t *) (CONFIG_EEPROM_ADDR_LED_SMOOTH); - config->led_co2_alert_limit1 = *(uint16_t *) (CONFIG_EEPROM_ADDR_LED_ALERT1); - config->led_co2_alert_limit2 = *(uint16_t *) (CONFIG_EEPROM_ADDR_LED_ALERT2); - config->scd4x_t_offset = *(int16_t *) (CONFIG_EEPROM_ADDR_SCD4x_T_OFFSET); /* Check if the EEPROM is initialized - do not check: - * LED ON - * LED SMOOTH - * SCD4x T OFFSET * BAUDRATE INDEX * those can be 0 */ - if ((config->modbus_addr == EEPROM_EMPTY_BYTE) || - (config->led_co2_alert_limit1 == EEPROM_EMPTY_BYTE) || - (config->led_co2_alert_limit2 == EEPROM_EMPTY_BYTE) || - (config->led_brightness == EEPROM_EMPTY_BYTE)) + if (config->modbus_addr == EEPROM_EMPTY_BYTE) { return CONFIG_ERROR; } @@ -82,48 +70,13 @@ int8_t config_write(config_t *config) { return EEPROM_WRITE_ERROR; } + /* Write BAUDRATE */ if (eeprom_program_halfword(CONFIG_EEPROM_ADDR_BAUDRATE_INDEX, config->baudrate_index) != EEPROM_OK) { return EEPROM_WRITE_ERROR; } - /* Write LED ON */ - if (eeprom_program_byte(CONFIG_EEPROM_ADDR_LED_ON, config->led_on) != EEPROM_OK) - { - return EEPROM_WRITE_ERROR; - } - - /* Write LED BRIGHTNESS */ - if (eeprom_program_halfword(CONFIG_EEPROM_ADDR_LED_BRIGHTNESS, config->led_brightness) != EEPROM_OK) - { - return EEPROM_WRITE_ERROR; - } - - /* Write LED SMOOTH */ - if (eeprom_program_byte(CONFIG_EEPROM_ADDR_LED_SMOOTH, config->led_smooth) != EEPROM_OK) - { - return EEPROM_WRITE_ERROR; - } - - /* Write LED CO2 ALERT LIMIT 1 */ - if (eeprom_program_halfword(CONFIG_EEPROM_ADDR_LED_ALERT1, config->led_co2_alert_limit1) != EEPROM_OK) - { - return EEPROM_WRITE_ERROR; - } - - /* Write LED CO2 ALERT LIMIT 2 */ - if (eeprom_program_halfword(CONFIG_EEPROM_ADDR_LED_ALERT2, config->led_co2_alert_limit2) != EEPROM_OK) - { - return EEPROM_WRITE_ERROR; - } - - /* Write LED SCD4x TEMPERATURE OFFSET */ - if (eeprom_program_halfword(CONFIG_EEPROM_ADDR_SCD4x_T_OFFSET, config->scd4x_t_offset) != EEPROM_OK) - { - return EEPROM_WRITE_ERROR; - } - /* Lock EEPROM*/ if (eeprom_lock() != EEPROM_OK) { diff --git a/fw/Core/Src/crc8.c b/fw/Core/Src/crc8.c deleted file mode 100644 index 312cdf4..0000000 --- a/fw/Core/Src/crc8.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * crc.c - * - * Created on: Jun 9, 2021 - * Author: user - */ - -#include "crc8.h" - -/* Stolen from Sensirion SCD4x datasheet, section 3.11 */ -uint8_t crc8_calculate(const uint8_t *data, uint16_t count) -{ - uint16_t current_byte; - uint8_t crc = CRC8_INIT; - uint8_t crc_bit; - /* calculates 8-Bit checksum with given polynomial */ - for (current_byte = 0; current_byte < count; ++current_byte) { - crc ^= (data[current_byte]); - for(crc_bit = 8; crc_bit > 0; --crc_bit) { - if (crc & 0x80) { - crc =(crc << 1) ^ CRC8_POLYNOMIAL; - } else { - crc = (crc << 1); - } - } - } - return crc; -} diff --git a/fw/Core/Src/ltr329.c b/fw/Core/Src/ltr329.c deleted file mode 100644 index 6918d7d..0000000 --- a/fw/Core/Src/ltr329.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * ltr329.c - * - * Created on: May 22, 2022 - * Author: david - */ -#include "ltr329.h" -#include "main.h" /* for uart_disable_interrupts() */ - -static int8_t ltr329_read_register (ltr329_cmd_t register_addr, uint8_t *register_data ) -{ - uint8_t tx_buffer[1]; - uint8_t rx_buffer[1]; - int result; - - // start measurement - tx_buffer[0] = register_addr; - /* disable interrupts to prevent modbus/i2c conflict */ - uart_disable_interrupts(); - result = i2c_transmit(LTR329_I2C_ADDRESS<<1, tx_buffer, 1); - uart_enable_interrupts(); - if (result != I2C_OK) { - return LTR329_ERROR; - } - LL_mDelay(10); /* 10 ms should be enough */ - /* read out */ - uart_disable_interrupts(); - result = i2c_receive(LTR329_I2C_ADDRESS<<1, rx_buffer, 1); - uart_enable_interrupts(); - if (result != I2C_OK) { - return LTR329_ERROR; - } - - *register_data = rx_buffer[0]; - return LTR329_OK; -} - -static int8_t ltr329_write_register (ltr329_cmd_t register_addr, uint8_t register_data) -{ - uint8_t tx_buffer[2]; - int result; - - // start measurement - tx_buffer[0] = register_addr; - tx_buffer[1] = register_data; - /* disable interrupts to prevent modbus/i2c conflict */ - uart_disable_interrupts(); - result = i2c_transmit(LTR329_I2C_ADDRESS<<1, tx_buffer, 2); - uart_enable_interrupts(); - if (result != I2C_OK) { - return LTR329_ERROR; - } - return LTR329_OK; -} - -int8_t ltr329_write_settings (ltr329_gain_t gain, ltr329_als_mode_t mode, ltr329_integration_time_t integ_time, ltr329_measurement_rate_t meas_rate) -{ - int8_t result; - /* Write Gain and ALS Mode */ - result = ltr329_write_register(LTR329_ALS_CONTR, (gain | mode)); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - /* Write Integration Time and Measurement Rate */ - - result = ltr329_write_register(LTR329_ALS_MEAS_RATE, (integ_time | meas_rate)); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - return LTR329_OK; -} - -int8_t ltr329_read_settings (ltr329_gain_t *gain, ltr329_als_mode_t *mode, ltr329_integration_time_t *integ_time, ltr329_measurement_rate_t *meas_rate) -{ - int8_t result; - uint8_t control_register_data; - uint8_t rate_register_data; - - result = ltr329_read_register(LTR329_ALS_CONTR, &control_register_data); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - - result = ltr329_read_register(LTR329_ALS_MEAS_RATE, &rate_register_data); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - - uint8_t control_register_gain_mask = 0b00011100; - uint8_t control_register_mode_mask = 0b00000001; - uint8_t rate_register_int_time_mask = 0b00111000; - uint8_t rate_register_rate_mask = 0b00000111; - - /* Return Registers Values */ - /* TODO: This might not be safe */ - *gain = control_register_data & control_register_gain_mask; - *mode = control_register_data & control_register_mode_mask; - *integ_time = rate_register_data & rate_register_int_time_mask; - *meas_rate = rate_register_data & rate_register_rate_mask; - - return LTR329_OK; -} - -int8_t ltr329_sw_reset( void ) -{ - int8_t result; - /* Write Gain and ALS Mode */ - result = ltr329_write_register(LTR329_ALS_CONTR, 0b00000010); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - return LTR329_OK; -} - -int8_t ltr329_measure (uint16_t *data_ch0, uint16_t *data_ch1) -{ - uint8_t ch0_l, ch0_h, ch1_l, ch1_h; - int result; - result = ltr329_read_register(LTR329_ALS_DATA_CH0_0, &ch0_l); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - result = ltr329_read_register(LTR329_ALS_DATA_CH0_1, &ch0_h); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - result = ltr329_read_register(LTR329_ALS_DATA_CH1_0, &ch1_l); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - result = ltr329_read_register(LTR329_ALS_DATA_CH1_1, &ch1_h); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - - *data_ch0 = (ch0_h << 8) + ch0_l; - *data_ch1 = (ch1_h << 8) + ch1_l; - return LTR329_OK; -} - -int8_t ltr329_read_status_register(uint8_t *data_valid, uint8_t *new_data, ltr329_gain_t *gain) -{ - int8_t result; - uint8_t status_register_data; - result = ltr329_read_register(LTR329_ALS_STATUS, &status_register_data); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - - /* Check data valid */ - uint8_t data_invalid_mask = 0b10000000; - if ((status_register_data & data_invalid_mask) == data_invalid_mask) - { - *data_valid = 0; - } else - { - *data_valid = 1; - } - - /* Check if there is new data */ - uint8_t data_status_mask = 0b00000100; - if ((status_register_data & data_status_mask) == data_status_mask) - { - *new_data = 1; - } else - { - *new_data = 0; - } - - /* Check Gain */ - /* TODO: This might not be safe */ - uint8_t gain_mask = 0b01110000; - *gain = status_register_data & gain_mask; - - return LTR329_OK; -} - -int8_t ltr329_read_device_info (uint8_t *manufacturer_id, uint8_t *part_id) -{ - int8_t result; - result = ltr329_read_register(LTR329_MANUFAC_ID, manufacturer_id); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - result = ltr329_read_register(LTR329_PART_ID, part_id); - if (result != LTR329_OK) - { - return LTR329_ERROR; - } - return LTR329_OK; -} diff --git a/fw/Core/Src/main.c b/fw/Core/Src/main.c index ef371fd..7a9a664 100644 --- a/fw/Core/Src/main.c +++ b/fw/Core/Src/main.c @@ -74,27 +74,26 @@ enum { REGISTER_NUM_T = 30010, /* deg C */ REGISTER_NUM_T_F = 30011, /* deg F */ - REGISTER_NUM_RH = 30012 /* %, from SHT4x */ - + REGISTER_NUM_RH = 30012, /* %, from SHT4x */ + REGISTER_NUM_LIGHT_INTENSITY_0 = 30013, /* ticks, from LTR329 */ /*TODO: Find out what it is */ + REGISTER_NUM_LIGHT_INTENSITY_1 = 30014, /* ticks, from LTR329 */ /*TODO: Find out what it is */ + REGISTER_NUM_DEVICE_IDENTIFIER = 30100 /* VOC Index has initial blackout beriod, when the data is not ready. VOC index is 0 during this period */ } data_registers_numbers; enum { + REGISTER_NUM_LTR329_GAIN = 40001, + REGISTER_NUM_LTR329_MEAS_RATE = 40002, + REGISTER_NUM_LTR329_INTEGRATION_TIME = 40003, + REGISTER_NUM_LTR329_MODE = 40004, + /* TODO: Change registers to start with the modbus specific settings? */ + /* TODO: Seal the gap */ REGISTER_NUM_MODBUS_ADDR = 40007, REGISTER_NUM_BAUDRATE = 40008, REGISTER_NUM_RESET_DEVICE = 40100 } config_registers_numbers; -enum -{ - REGISTER_NUM_VENDOR_NAME = 30010, - REGISTER_NUM_PRODUCT_CODE = 30011, - REGISTER_NUM_REVISION = 30012, - REGISTER_NUM_PRODUCT_NAME = 30013, - REGISTER_NUM_SERIAL_NUMBER = 30014 -} identification_registers_numbers; - /* Variables to store the measured data */ int16_t T_SHT4x, TF_SHT4x; uint16_t RH_SHT4x; @@ -106,6 +105,7 @@ config_t sensor_config; modbus_device_id_t device_id; uint8_t sensor_config_pending_write = 0; uint8_t baudrate_changed = 0; +uint8_t ltr329_config_changed = 0; uint8_t modbus_address_changed = 0; uint8_t co2_valid = 0; @@ -126,6 +126,54 @@ void USART2_TX_Buffer(uint8_t* buffer_tx, uint16_t buffer_tx_len); /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ +int8_t sht4x_i2c_transmit(uint8_t address, uint8_t *buffer, int len) +{ + return i2c_transmit(address, buffer, len); +} + +int8_t sht4x_i2c_receive(uint8_t address, uint8_t *buffer, int len) +{ + return i2c_receive(address, buffer, len); +} + +uint8_t sensirion_crc8_calculate(const uint8_t *data, uint16_t count) +{ + return crc8_calculate(data, count); +} + +int8_t sht4x_disable_interrupts(void) +{ + return uart_disable_interrupts(); +} + +int8_t sht4x_enable_interrupts(void) +{ + return uart_enable_interrupts(); +} + +int8_t ltr329_i2c_transmit(uint8_t address, uint8_t *buffer, int len) +{ + return i2c_transmit(address, buffer, len); +} +int8_t ltr329_i2c_receive(uint8_t address, uint8_t *buffer, int len) +{ + return i2c_receive(address, buffer, len); +} + +int8_t ltr329_disable_interrupts(void) +{ + return uart_disable_interrupts(); +} + +int8_t ltr329_enable_interrupts(void) +{ + return uart_enable_interrupts(); +} + +void delay_ms(int delay_ms) +{ + LL_mDelay(delay_ms); +} /* USER CODE END 0 */ /** @@ -162,12 +210,6 @@ int main(void) if (config_read_status != CONFIG_OK) { sensor_config.modbus_addr = MODBUS_DEFAULT_SLAVE_ADDRESS; - sensor_config.led_co2_alert_limit1 = CONFIG_DEFAULT_LED_ALERT1_LIMIT; - sensor_config.led_co2_alert_limit2 = CONFIG_DEFAULT_LED_ALERT2_LIMIT; - sensor_config.led_on = CONFIG_DEFAULT_LED_ON; - sensor_config.led_brightness = CONFIG_DEFAULT_LED_BRIGHTNESS; - sensor_config.led_smooth = CONFIG_DEFAULT_LED_SMOOTH; - sensor_config.scd4x_t_offset = CONFIG_DEFAULT_SCD4x_T_OFFSET; sensor_config.baudrate_index = CONFIG_DEFAULT_BAUDRATE_INDEX; } /* USER CODE END SysInit */ @@ -231,7 +273,16 @@ int main(void) ltr_ret = ltr329_write_settings(LTR329_GAIN_48X, LTR329_MODE_ACTIVE, LTR329_INTEGRATION_100MS, LTR329_MEAS_RATE_100MS); /* TODO: Check register status */ } while (ltr_ret != 0); - + /* LTR329 Innitialized */ + ltr329_gain_t ltr329_gain; + ltr329_als_mode_t ltr329_mode; + ltr329_integration_time_t ltr329_int_time; + ltr329_measurement_rate_t ltr329_meas_rate; + ltr329_read_settings(<r329_gain, <r329_mode, <r329_int_time, <r329_meas_rate); + sensor_config.ltr329_gain = ltr329_gain; + sensor_config.ltr329_mode = ltr329_mode; + sensor_config.ltr329_integ_time = ltr329_int_time; + sensor_config.ltr329_meas_rate = ltr329_meas_rate; static uint32_t new_baud; /* Enter the main loop */ @@ -263,8 +314,10 @@ int main(void) } /* if config changed (MODBUS write), reflect changes to EEPROM */ if (sensor_config_pending_write) { + uart_disable_interrupts(); config_write(&sensor_config); sensor_config_pending_write = 0; + uart_enable_interrupts(); } if (modbus_address_changed) { @@ -284,6 +337,11 @@ int main(void) new_baud = LL_USART_GetBaudRate(USART2, SYSTICK_FREQ_HZ, LL_USART_OVERSAMPLING_16); } + if(ltr329_config_changed) + { + ltr329_write_settings(sensor_config.ltr329_gain, sensor_config.ltr329_mode, sensor_config.ltr329_integ_time, sensor_config.ltr329_meas_rate); + ltr329_config_changed = 0; + } /* It is time for measurement */ if (tim21_elapsed_period == 1) { @@ -640,6 +698,12 @@ int8_t modbus_slave_callback(modbus_transaction_t *transaction) case REGISTER_NUM_RH: transaction->input_registers[i] = (uint16_t)RH_SHT4x; break; + case REGISTER_NUM_LIGHT_INTENSITY_0: + transaction->input_registers[i] = (uint16_t)light_ch0; + break; + case REGISTER_NUM_LIGHT_INTENSITY_1: + transaction->input_registers[i] = (uint16_t)light_ch1; + break; default: return MODBUS_ERROR_FUNCTION_NOT_IMPLEMENTED; } @@ -656,6 +720,22 @@ int8_t modbus_slave_callback(modbus_transaction_t *transaction) case REGISTER_NUM_BAUDRATE: transaction->holding_registers[i] = (uint16_t)(sensor_config.baudrate_index); break; + case REGISTER_NUM_LTR329_GAIN: + transaction->holding_registers[i] = (uint16_t)(sensor_config.ltr329_gain); + /* TODO : IMPLEMENT */ + break; + case REGISTER_NUM_LTR329_INTEGRATION_TIME: + transaction->holding_registers[i] = (uint16_t)(sensor_config.ltr329_integ_time); + /* TODO : IMPLEMENT */ + break; + case REGISTER_NUM_LTR329_MEAS_RATE: + transaction->holding_registers[i] = (uint16_t)(sensor_config.ltr329_meas_rate); + /* TODO : IMPLEMENT */ + break; + case REGISTER_NUM_LTR329_MODE: + transaction->holding_registers[i] = (uint16_t)(sensor_config.ltr329_mode); + /* TODO : IMPLEMENT */ + break; default: return MODBUS_ERROR_FUNCTION_NOT_IMPLEMENTED; } @@ -693,6 +773,56 @@ int8_t modbus_slave_callback(modbus_transaction_t *transaction) return MODBUS_ERROR_OUT_OF_BOUNDS; } break; + case REGISTER_NUM_LTR329_GAIN: + if (transaction->holding_registers[i] != LTR329_GAIN_1X || + transaction->holding_registers[i] != LTR329_GAIN_2X || + transaction->holding_registers[i] != LTR329_GAIN_4X || + transaction->holding_registers[i] != LTR329_GAIN_8X || + transaction->holding_registers[i] != LTR329_GAIN_48X || + transaction->holding_registers[i] != LTR329_GAIN_96X) + { + return MODBUS_ERROR_OUT_OF_BOUNDS; + } + sensor_config.ltr329_gain = (ltr329_gain_t) (transaction->holding_registers[i]); + ltr329_config_changed = 1; + break; + case REGISTER_NUM_LTR329_INTEGRATION_TIME: + if (transaction->holding_registers[i] != LTR329_INTEGRATION_50MS || + transaction->holding_registers[i] != LTR329_INTEGRATION_100MS || + transaction->holding_registers[i] != LTR329_INTEGRATION_150MS || + transaction->holding_registers[i] != LTR329_INTEGRATION_200MS || + transaction->holding_registers[i] != LTR329_INTEGRATION_250MS || + transaction->holding_registers[i] != LTR329_INTEGRATION_300MS || + transaction->holding_registers[i] != LTR329_INTEGRATION_350MS || + transaction->holding_registers[i] != LTR329_INTEGRATION_400MS) + { + return MODBUS_ERROR_OUT_OF_BOUNDS; + } + sensor_config.ltr329_integ_time = (ltr329_integration_time_t) (transaction->holding_registers[i]); + ltr329_config_changed = 1; + break; + case REGISTER_NUM_LTR329_MEAS_RATE: + if (transaction->holding_registers[i] != LTR329_MEAS_RATE_50MS || + transaction->holding_registers[i] != LTR329_MEAS_RATE_100MS || + transaction->holding_registers[i] != LTR329_MEAS_RATE_200MS || + transaction->holding_registers[i] != LTR329_MEAS_RATE_500MS || + transaction->holding_registers[i] != LTR329_MEAS_RATE_1000MS || + transaction->holding_registers[i] != LTR329_MEAS_RATE_2000MS) + { + return MODBUS_ERROR_OUT_OF_BOUNDS; + } + sensor_config.ltr329_meas_rate = (ltr329_measurement_rate_t) (transaction->holding_registers[i]); + ltr329_config_changed = 1; + break; + case REGISTER_NUM_LTR329_MODE: + if (transaction->holding_registers[i] != LTR329_MODE_STAND_BY || + transaction->holding_registers[i] != LTR329_MODE_ACTIVE) + { + return MODBUS_ERROR_OUT_OF_BOUNDS; + } + sensor_config.ltr329_mode = (ltr329_als_mode_t) (transaction->holding_registers[i]); + ltr329_config_changed = 1; + break; default: return MODBUS_ERROR_FUNCTION_NOT_IMPLEMENTED; } diff --git a/fw/Core/Src/modbus.c b/fw/Core/Src/modbus.c deleted file mode 100644 index ddf37b6..0000000 --- a/fw/Core/Src/modbus.c +++ /dev/null @@ -1,431 +0,0 @@ -/* - * modbus.c - * - * Created on: Jul 18, 2021 - * Author: user - */ - -#include "modbus.h" - -/* - * Global variables - */ - -/* Modbus TX buffer; can be also used for RX in memory constrained systems (e.g. in main.c); - * NOTE if shared buffer is used for TX/RX, care must be taken to prevent writing into buffer - * during execution of modbus_process_message() */ -uint8_t modbus_buffer[MODBUS_MAX_RTU_FRAME_SIZE]; - -/* MODBUS device address */ -uint8_t modbus_slave_address = MODBUS_DEFAULT_SLAVE_ADDRESS; - -/* Device ID struct */ -modbus_device_id_t *modbus_device_id = NULL; - -/* - * CRC16 functions - * see https://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf - * section 6.2.2 - */ - -/* CRC16 (without memory mapped values) - * taken from https://ctlsys.com/support/how_to_compute_the_modbus_rtu_message_crc/ */ -uint16_t modbus_CRC16(const uint8_t *buf, int len) -{ - uint16_t crc = 0xFFFF; - - for (int pos = 0; pos < len; pos++) { - crc ^= (uint16_t)buf[pos]; // XOR byte into least sig. byte of crc - - for (int i = 8; i != 0; i--) { // Loop over each bit - if ((crc & 0x0001) != 0) { // If the LSB is set - crc >>= 1; // Shift right and XOR 0xA001 - crc ^= 0xA001; - } else { // Else LSB is not set - crc >>= 1; // Just shift right - } - } - } - // Note, this number has low and high bytes swapped, so use it accordingly (or swap bytes) - return crc; -} - -/* - * Private functions - */ - -static uint8_t modbus_fill_device_id_objects(uint8_t *buffer, modbus_transaction_t *transaction) -{ - /* we assume buffer is 256 - MODBUS_READ_DEVICE_ID_RESPONSE_HEADER_LEN = 252 bytes long */ - /* find out how many objects we copy to buffer */ - int len; - uint8_t object_index = transaction->object_id; - uint8_t object_count; - uint8_t more_follows = MODBUS_NO_MORE_FOLLOWS; - uint8_t next_object_id; - uint8_t last_object; - const uint8_t max_len = 256 - MODBUS_READ_DEVICE_ID_RESPONSE_HEADER_LEN; - - /* last object index */ - if (transaction->read_device_id_code == MODBUS_CONFORMITY_BASIC) { - last_object = MODBUS_BASIC_OBJECT_COUNT; - } else if (transaction->read_device_id_code == MODBUS_CONFORMITY_REGULAR) { - last_object = MODBUS_REGULAR_OBJECT_COUNT; - /* extended not implemented */ -// } else if (transaction->read_device_id_code == MODBUS_CONFORMITY_EXTENDED){ -// last_object = MODBUS_EXTENDED_OBJECT_COUNT; - } else { - /* fallback: regular */ - last_object = MODBUS_REGULAR_OBJECT_COUNT; - } - last_object--; // we need index - /* copy as many objects as possible */ - do { - /* copy object */ - int object_len = strlen(modbus_device_id->object_id[object_index]); - if (len + object_len + 2 > max_len) { - more_follows = MODBUS_MORE_FOLLOWS; - next_object_id = object_index; - break; - } - /* offset is for "more follows", "next object id", "object count" */ - buffer[MODBUS_READ_DEVICE_ID_RESPONSE_OFFSET + len++] = object_index; - buffer[MODBUS_READ_DEVICE_ID_RESPONSE_OFFSET + len++] = object_len; - /* note that string copied to buffer is not null-terminated */ - strncpy((char*)(buffer + len), (char*)modbus_device_id->object_id[object_index++], object_len); - len += object_len; - object_count++; - } while (object_index < last_object); - buffer[0] = more_follows; - buffer[1] = next_object_id; - buffer[2] = object_count; - return MODBUS_READ_DEVICE_ID_RESPONSE_OFFSET + len; -} - -/* here we assume buffer has minimal size of MODBUS_MAX_RTU_FRAME_SIZE; - * this function is private, so hopefully it's going to be ok */ -static int8_t modbus_transaction_to_buffer(uint8_t *buffer, uint8_t *msg_len, modbus_transaction_t *transaction) -{ - uint16_t crc16; - uint8_t byte_count; - uint8_t buffer_pos = 0; - - // TODO use relative indices (increments) instead of absolute - buffer[buffer_pos++] = modbus_slave_address; - buffer[buffer_pos++] = transaction->function_code; - *msg_len = 5; - - if (transaction->function_code & MODBUS_ERROR_FLAG) { - /* sending error reply */ - buffer[buffer_pos++] = transaction->exception; - } else { - switch (transaction->function_code) { - case MODBUS_READ_HOLDING_REGISTERS: - case MODBUS_READ_INPUT_REGISTERS: - byte_count = transaction->register_count * 2; - buffer[buffer_pos++] = byte_count; - *msg_len = byte_count + 5; - for (int i = 0; i < transaction->register_count; i++) { - // TODO endianness handling - /* buffer16b is alias for both holding and input register buffers */ - buffer[buffer_pos++] = transaction->buffer16b[i] >> 8; - buffer[buffer_pos++] = transaction->buffer16b[i] & 0xff; - } - break; - case MODBUS_WRITE_SINGLE_REGISTER: - buffer[buffer_pos++] = (uint8_t) (transaction->register_address >> 8); - buffer[buffer_pos++] = (uint8_t) transaction->register_address; - buffer[buffer_pos++] = (uint8_t) (transaction->holding_registers[0] >> 8); - buffer[buffer_pos++] = (uint8_t) transaction->holding_registers[0]; - *msg_len = 8; /* includes 2 bytes for CRC */ - break; - case MODBUS_WRITE_MULTIPLE_REGISTERS: - buffer[buffer_pos++] = (uint8_t) (transaction->register_address >> 8); - buffer[buffer_pos++] = (uint8_t) transaction->register_address; - buffer[buffer_pos++] = (uint8_t) (transaction->register_count >> 8); - buffer[buffer_pos++] = (uint8_t) transaction->register_count; - *msg_len = 8; /* includes 2 bytes for CRC */ - break; - case MODBUS_READ_DEVICE_IDENTIFICATION: - /* MEI type */ - buffer[buffer_pos++] = MODBUS_MEI; - /* read device id */ - buffer[buffer_pos++] = transaction->read_device_id_code; - /* conformity level */ - buffer[buffer_pos++] = modbus_device_id->conformity_level; - /* fill buffer with as many objects as possible */ - *msg_len = modbus_fill_device_id_objects(buffer+buffer_pos, transaction); - *msg_len += 7; /* includes 2 bytes for CRC */ - break; - } - } - crc16 = modbus_CRC16(buffer, buffer_pos); /* last two bytes is the checksum itself */ - buffer[buffer_pos++] = crc16 & 0xff; - buffer[buffer_pos++] = crc16 >> 8; - return MODBUS_OK; -} - -static int8_t modbus_process_device_id_request(const uint8_t *buffer, int len, modbus_transaction_t *transaction) -{ - uint8_t MEI_type; - uint8_t read_device_id_code; - uint8_t object_id; - uint8_t buffer_pos = 0; - - if (transaction->broadcast == 1) { - /* Read device ID broadcast - invalid; ignore (master will get timeout) */ - return MODBUS_ERROR; - } - if (modbus_device_id == NULL) { - /* modbus_device_id not initialized; user should use modbus_slave_init_device_id() first */ - transaction->exception = MODBUS_EXCEPTION_ILLEGAL_DEVICE_ID_CODE; - return MODBUS_OK; - } - if (len < MODBUS_READ_DEVICE_ID_REQUEST_LEN) { - /* frame too short, ignore */ - return MODBUS_ERROR; - } - /* next byte should be MEI = 0x0E */ - MEI_type = buffer[buffer_pos++]; - if (MEI_type != MODBUS_MEI) { - /* invalid MEI, ignore. I have no idea what MEI does, but it should always be 0x0E */ - return MODBUS_ERROR; - } - /* next byte is read device id code */ - read_device_id_code = buffer[buffer_pos++]; - /* read device id code can only have values 1,2,3,4 */ - if (read_device_id_code < 1 || read_device_id_code > 4) { - transaction->exception = MODBUS_EXCEPTION_ILLEGAL_DEVICE_ID_CODE; - return MODBUS_OK; - } - transaction->read_device_id_code = read_device_id_code; - /* next byte is object id */ - object_id = buffer[buffer_pos++]; - transaction->object_id = object_id; - if (object_id > MODBUS_DEVICE_ID_OBJECT_NUM) { - /* illegal object ID */ - transaction->exception = MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS; - return MODBUS_OK; - } - /* Message processed */ - return MODBUS_OK; -} - -/* returns ERROR only when no response to master is needed */ -static int8_t modbus_process_read_write_request(const uint8_t *buffer, int len, modbus_transaction_t *transaction) -{ - uint8_t byte_count; - int8_t callback_result; - uint8_t buffer_pos = 0; - - /* set starting register number */ - switch (transaction->function_code) { - /* coils */ - case MODBUS_READ_DO: - case MODBUS_WRITE_SINGLE_DO: - case MODBUS_WRITE_MULTIPLE_DO: - transaction->register_number = MODBUS_DO_START_NUMBER; - break; - /* discrete inputs */ - case MODBUS_READ_DI: - transaction->register_number = MODBUS_DI_START_NUMBER; - break; - /* input registers */ - case MODBUS_READ_AI: - transaction->register_number = MODBUS_AI_START_NUMBER; - break; - /* holding registers */ - case MODBUS_READ_AO: - case MODBUS_WRITE_SINGLE_AO: - case MODBUS_WRITE_MULTIPLE_AO: - case MODBUS_READ_WRITE_MULTIPLE_REGISTERS: - transaction->register_number = MODBUS_AO_START_NUMBER; - break; - } - - #define MODBUS_FLAG_WRITE 0x01 - #define MODBUS_FLAG_SINGLE 0x02 - uint8_t flags = 0x00; - - /* process message */ - switch (transaction->function_code) { - case MODBUS_WRITE_SINGLE_COIL: - case MODBUS_WRITE_SINGLE_REGISTER: /* holding register */ - flags |= MODBUS_FLAG_SINGLE; - case MODBUS_WRITE_MULTIPLE_COILS: - case MODBUS_WRITE_MULTIPLE_REGISTERS: - flags |= MODBUS_FLAG_WRITE; - case MODBUS_READ_DISCRETE_INPUTS: - case MODBUS_READ_COILS: - case MODBUS_READ_INPUT_REGISTERS: - case MODBUS_READ_HOLDING_REGISTERS: - if (len < MODBUS_MINIMAL_READWRITE_LEN) { - /* buffer too short to contain everything we need */ - return MODBUS_ERROR; - } - transaction->register_address = (buffer[buffer_pos] << 8) | buffer[buffer_pos + 1]; - buffer += 2; - // TODO check length! - if (flags & MODBUS_FLAG_WRITE) { - if (flags & MODBUS_FLAG_SINGLE) { - transaction->holding_registers[0] = (buffer[buffer_pos] << 8) | buffer[buffer_pos + 1]; - buffer_pos += 2; - } else { - /* Write multiple registers */ - transaction->register_count = (buffer[buffer_pos] << 8) | buffer[buffer_pos + 1]; - buffer_pos += 2; - if (len < MODBUS_MINIMAL_WRITE_MULTIPLE_LEN) { - return MODBUS_ERROR; - } - byte_count = buffer[buffer_pos++]; - if (transaction->register_count > 123 || 2*transaction->register_count != byte_count) { - /* Max number of register is defined by Modbus_Application_Protocol_V1_1b, section 6.12 */ - transaction->exception = MODBUS_EXCEPTION_ILLEGAL_REGISTER_QUANTITY; - } else { - if (len < MODBUS_MINIMAL_WRITE_MULTIPLE_LEN + byte_count) { - return MODBUS_ERROR; - } - for (uint8_t i = 0; i < transaction->register_count; i++) { - transaction->holding_registers[i] = (buffer[buffer_pos] << 8) | buffer[buffer_pos + 1]; - buffer_pos += 2; - } - } - } - } else { - transaction->register_count = (buffer[buffer_pos] << 8) | buffer[buffer_pos + 1]; - buffer_pos += 2; - if ( - transaction->register_count < 1 || - transaction->register_count > MODBUS_MAX_REGISTERS - ) { - transaction->exception = MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE; - } - } - // add offset to register number - transaction->register_number += transaction->register_address; - break; - default: - /* function code not known / not implemented, reply with - * ExceptionCode 1 */ - transaction->exception = MODBUS_EXCEPTION_ILLEGAL_FUNCTION; - break; - } - /* data in modbus_buffer have been processed and buffer can be re-used for TX */ - /* handle reply */ - if (transaction->exception != 0) { - /* indicate error */ - transaction->function_code |= MODBUS_ERROR_FLAG; - } else { - callback_result = modbus_slave_callback(transaction); - /* error handling */ - if (callback_result != MODBUS_OK) { - transaction->function_code |= MODBUS_ERROR_FLAG; - if (callback_result == MODBUS_ERROR_FUNCTION_NOT_IMPLEMENTED) { - transaction->exception = MODBUS_EXCEPTION_ILLEGAL_FUNCTION; - } else if (callback_result == MODBUS_ERROR_REGISTER_NOT_IMPLEMENTED) { - transaction->exception = MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS; - } - } - } - return MODBUS_OK; -} - -/* - * Public function definitions - */ - -int8_t modbus_slave_set_address(uint8_t address) -{ - if (address == 0) { - /* address 0 is broadcast address */ - return MODBUS_ERROR; - } - modbus_slave_address = address; - return MODBUS_OK; -} - - -int8_t modbus_slave_process_msg(const uint8_t *buffer, int len) -{ - - - /* - * TODO list: - * - * 1) check that errors and exceptions are handled according to Modbus_Application_Protocol_V1_1b.pdf - * 2) buffer overflow prevention: for each function code, check that buffer is long enough - */ - - - /* transaction holds message context and content: - * it wraps all necessary buffers and variables */ - modbus_transaction_t transaction; - uint8_t buffer_pos = 0; - - if (len < MODBUS_MINIMAL_FRAME_LEN) { - /* frame too short; return error (no reply needed) */ - return MODBUS_ERROR_FRAME_INVALID; - } - /* check CRC first */ - uint16_t crc_received = (buffer[len - 1] << 8) | buffer[len - 2]; - uint16_t crc_calculated = modbus_CRC16(buffer, len - 2); - if (crc_received != crc_calculated) { - /* CRC mismatch, return error (no reply needed) */ - return MODBUS_ERROR_CRC; - } - /* check if address matches ours */ - uint8_t address = buffer[buffer_pos++]; - transaction.broadcast = (address == MODBUS_BROADCAST_ADDR); - if (address != modbus_slave_address && transaction.broadcast != 1) { - /* Message is not for us (no reply needed) */ - return MODBUS_OK; - } - /* get function code */ - transaction.function_code = buffer[buffer_pos++]; - transaction.exception = 0; - uint8_t request_processing_result; - if (transaction.function_code == MODBUS_READ_DEVICE_IDENTIFICATION) { - /* Read device ID request is quite complicated, therefore it has its own processing function */ - request_processing_result = modbus_process_device_id_request(buffer + buffer_pos, len - buffer_pos, &transaction); - } else { - /* process other requests: input register read, holding register read/write */ - request_processing_result = modbus_process_read_write_request(buffer + buffer_pos, len - buffer_pos, &transaction); - } - uint8_t msg_len; - /* reply only if request was processed successfully and message was not broadcast */ - if (request_processing_result == MODBUS_OK && transaction.broadcast == 0) { - modbus_transaction_to_buffer(modbus_buffer, &msg_len, &transaction); - /* send reply */ - modbus_transmit_function(modbus_buffer, msg_len); - } - return MODBUS_OK; -} - -int8_t modbus_slave_init_device_id(modbus_device_id_t *device_id) -{ - if (device_id == NULL) { - return MODBUS_ERROR; - } - /* at least basic category objects have to be implemented */ - if ( device_id->object_name.VendorName == NULL || - device_id->object_name.ProductCode == NULL || - device_id->object_name.MajorMinorRevision == NULL - ) { - return MODBUS_ERROR; - } - /* set conformity level: currently only "basic" and "regular" is implemented */ - if ( device_id->object_id[3] != NULL && - device_id->object_id[4] != NULL && - device_id->object_id[5] != NULL - - ) { - /* strings are present in regular category (optional) */ - device_id->conformity_level = MODBUS_CONFORMITY_REGULAR; - } else { - device_id->conformity_level = MODBUS_CONFORMITY_BASIC; - } - /* we support both stream and individual access to objects */ - device_id->conformity_level |= MODBUS_DEVICE_ID_INDIVIDUAL_ACCESS_FLAG; - modbus_device_id = device_id; - return MODBUS_OK; -} diff --git a/fw/Core/Src/sht4x.c b/fw/Core/Src/sht4x.c deleted file mode 100644 index e17cdf9..0000000 --- a/fw/Core/Src/sht4x.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * sht4x.c - * - * Created on: Jun 8, 2021 - * Author: user - */ - -#include "sht4x.h" -#include "main.h" /* for uart_disable_interrupts() */ - -int8_t sht4x_send_cmd(sht4x_cmd_t cmd) -{ - return SHT4X_OK; -} - -int8_t sht4x_read_data(uint8_t *buffer, int len) -{ - return SHT4X_OK; -} - -int8_t sht4x_measure(int16_t *temperature, uint16_t *relative_humidity) -{ - uint8_t buffer[32]; - int result; - - /* disable interrupts to prevent modbus/i2c conflict */ - // start measurement - buffer[0] = SHT4X_START_MEAS_HIGH_PRECISION; - uart_disable_interrupts(); - result = i2c_transmit(SHT4X_I2C_ADDRESS<<1, buffer, 1); - uart_enable_interrupts(); - if (result != I2C_OK) { - return SHT4X_ERROR; - } - LL_mDelay(10); /* 10 ms should be enough */ - /* read out */ - uart_disable_interrupts(); - result = i2c_receive(SHT4X_I2C_ADDRESS<<1, buffer, 6); - uart_enable_interrupts(); - if (result != I2C_OK) { - return SHT4X_ERROR; - } - /* Convert to T and RH; taken directly from pseudocode in SHT4x datasheet, page 3 */ - uint32_t t_ticks = (buffer[0] << 8) + buffer[1]; - uint8_t t_crc = buffer[2]; - uint32_t rh_ticks = (buffer[3] << 8) + buffer[4]; - uint8_t rh_crc = buffer[5]; - /* check CRC-8 checksum */ - uint8_t crc_correct = crc8_calculate(buffer, 2) == t_crc; - crc_correct &= crc8_calculate(buffer + 3, 2) == rh_crc; - if (!crc_correct) { - return SHT4X_CRC8_ERROR; - } - /* copy data to output variables */ - int t_degC = -450 + 10 * 175 * t_ticks / 65535; /* temperature * 10 */ - int rh_pRH = -6 + 125 * rh_ticks / 65535; - if (rh_pRH > 100) { - rh_pRH = 100; - } - if (rh_pRH < 0) { - rh_pRH = 0; - } - *temperature = t_degC; - *relative_humidity = rh_pRH; - - return SHT4X_OK; -} diff --git a/fw/Debug/Core/Src/config.d b/fw/Debug/Core/Src/config.d index 7f22991..cad1526 100644 --- a/fw/Debug/Core/Src/config.d +++ b/fw/Debug/Core/Src/config.d @@ -5,7 +5,11 @@ Core/Src/config.o: ../Core/Src/config.c ../Core/Inc/config.h \ ../Drivers/CMSIS/Include/cmsis_version.h \ ../Drivers/CMSIS/Include/cmsis_compiler.h \ ../Drivers/CMSIS/Include/cmsis_gcc.h \ - ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h + ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h \ + /home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329/ltr329.h \ + ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h \ + ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h \ + ../Core/Inc/i2c.h ../Core/Inc/config.h: @@ -22,3 +26,11 @@ Core/Src/config.o: ../Core/Src/config.c ../Core/Inc/config.h \ ../Drivers/CMSIS/Include/cmsis_gcc.h: ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h: + +/home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329/ltr329.h: + +../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h: + +../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h: + +../Core/Inc/i2c.h: diff --git a/fw/Debug/Core/Src/config.o b/fw/Debug/Core/Src/config.o index bc1ea56..15fb6a7 100644 Binary files a/fw/Debug/Core/Src/config.o and b/fw/Debug/Core/Src/config.o differ diff --git a/fw/Debug/Core/Src/config.su b/fw/Debug/Core/Src/config.su index 48bcb7f..d2b2412 100644 --- a/fw/Debug/Core/Src/config.su +++ b/fw/Debug/Core/Src/config.su @@ -1,7 +1,7 @@ config.c:43:8:config_read 16 static -config.c:70:8:config_write 16 static -config.c:135:15:eeprom_lock 24 static -config.c:165:15:eeprom_unlock 24 static -config.c:198:15:eeprom_program_byte 16 static -config.c:213:15:eeprom_program_halfword 16 static -config.c:229:15:eeprom_program_word 16 static +config.c:58:8:config_write 16 static +config.c:88:15:eeprom_lock 24 static +config.c:118:15:eeprom_unlock 24 static +config.c:151:15:eeprom_program_byte 16 static +config.c:166:15:eeprom_program_halfword 16 static +config.c:182:15:eeprom_program_word 16 static diff --git a/fw/Debug/Core/Src/crc8.d b/fw/Debug/Core/Src/crc8.d deleted file mode 100644 index 8c3a7ee..0000000 --- a/fw/Debug/Core/Src/crc8.d +++ /dev/null @@ -1,3 +0,0 @@ -Core/Src/crc8.o: ../Core/Src/crc8.c ../Core/Inc/crc8.h - -../Core/Inc/crc8.h: diff --git a/fw/Debug/Core/Src/crc8.o b/fw/Debug/Core/Src/crc8.o deleted file mode 100644 index ed3b814..0000000 Binary files a/fw/Debug/Core/Src/crc8.o and /dev/null differ diff --git a/fw/Debug/Core/Src/ltr329.d b/fw/Debug/Core/Src/ltr329.d deleted file mode 100644 index 3451003..0000000 --- a/fw/Debug/Core/Src/ltr329.d +++ /dev/null @@ -1,83 +0,0 @@ -Core/Src/ltr329.o: ../Core/Src/ltr329.c ../Core/Inc/ltr329.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h \ - ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l0xx.h \ - ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l031xx.h \ - ../Drivers/CMSIS/Include/core_cm0plus.h \ - ../Drivers/CMSIS/Include/cmsis_version.h \ - ../Drivers/CMSIS/Include/cmsis_compiler.h \ - ../Drivers/CMSIS/Include/cmsis_gcc.h \ - ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h \ - ../Core/Inc/i2c.h ../Core/Inc/main.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_iwdg.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_crs.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_rcc.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_bus.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_system.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_exti.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_cortex.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_pwr.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_dma.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_tim.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_usart.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_gpio.h \ - ../Core/Inc/sht4x.h ../Core/Inc/crc8.h ../Core/Inc/ltr329.h \ - ../Core/Inc/modbus.h ../Core/Inc/config.h - -../Core/Inc/ltr329.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h: - -../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l0xx.h: - -../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l031xx.h: - -../Drivers/CMSIS/Include/core_cm0plus.h: - -../Drivers/CMSIS/Include/cmsis_version.h: - -../Drivers/CMSIS/Include/cmsis_compiler.h: - -../Drivers/CMSIS/Include/cmsis_gcc.h: - -../Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h: - -../Core/Inc/i2c.h: - -../Core/Inc/main.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_iwdg.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_crs.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_rcc.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_bus.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_system.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_exti.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_cortex.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_pwr.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_dma.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_tim.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_usart.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_gpio.h: - -../Core/Inc/sht4x.h: - -../Core/Inc/crc8.h: - -../Core/Inc/ltr329.h: - -../Core/Inc/modbus.h: - -../Core/Inc/config.h: diff --git a/fw/Debug/Core/Src/ltr329.o b/fw/Debug/Core/Src/ltr329.o deleted file mode 100644 index b1fb5f6..0000000 Binary files a/fw/Debug/Core/Src/ltr329.o and /dev/null differ diff --git a/fw/Debug/Core/Src/ltr329.su b/fw/Debug/Core/Src/ltr329.su index 8609a1a..e69de29 100644 --- a/fw/Debug/Core/Src/ltr329.su +++ b/fw/Debug/Core/Src/ltr329.su @@ -1,8 +0,0 @@ -ltr329.c:10:15:ltr329_read_register 40 static -ltr329.c:38:15:ltr329_write_register 32 static -ltr329.c:56:8:ltr329_write_settings 32 static -ltr329.c:75:8:ltr329_read_settings 48 static -ltr329.c:108:8:ltr329_sw_reset 24 static -ltr329.c:120:8:ltr329_measure 24 static -ltr329.c:150:8:ltr329_read_status_register 40 static -ltr329.c:188:8:ltr329_read_device_info 32 static diff --git a/fw/Debug/Core/Src/main.d b/fw/Debug/Core/Src/main.d index 8e2f4fd..78d7757 100644 --- a/fw/Debug/Core/Src/main.d +++ b/fw/Debug/Core/Src/main.d @@ -20,8 +20,12 @@ Core/Src/main.o: ../Core/Src/main.c ../Core/Inc/main.h \ ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_tim.h \ ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_usart.h \ ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_gpio.h \ - ../Core/Inc/i2c.h ../Core/Inc/sht4x.h ../Core/Inc/crc8.h \ - ../Core/Inc/ltr329.h ../Core/Inc/modbus.h ../Core/Inc/config.h + ../Core/Inc/i2c.h \ + /home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/sht4x/sht4x.h \ + /home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329/ltr329.h \ + ../Core/Inc/i2c.h \ + /home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/modbus/modbus.h \ + ../Core/Inc/config.h ../Core/Inc/main.h: @@ -69,12 +73,12 @@ Core/Src/main.o: ../Core/Src/main.c ../Core/Inc/main.h \ ../Core/Inc/i2c.h: -../Core/Inc/sht4x.h: +/home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/sht4x/sht4x.h: -../Core/Inc/crc8.h: +/home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329/ltr329.h: -../Core/Inc/ltr329.h: +../Core/Inc/i2c.h: -../Core/Inc/modbus.h: +/home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/modbus/modbus.h: ../Core/Inc/config.h: diff --git a/fw/Debug/Core/Src/main.o b/fw/Debug/Core/Src/main.o index 496c6ac..4ccf3de 100644 Binary files a/fw/Debug/Core/Src/main.o and b/fw/Debug/Core/Src/main.o differ diff --git a/fw/Debug/Core/Src/main.su b/fw/Debug/Core/Src/main.su index 4939b09..ae64885 100644 --- a/fw/Debug/Core/Src/main.su +++ b/fw/Debug/Core/Src/main.su @@ -57,16 +57,26 @@ stm32l0xx_ll_usart.h:2996:22:LL_USART_EnableIT_RXNE 32 static,ignoring_inline_as stm32l0xx_ll_usart.h:3145:22:LL_USART_DisableIT_IDLE 32 static,ignoring_inline_asm stm32l0xx_ll_usart.h:3156:22:LL_USART_DisableIT_RXNE 32 static,ignoring_inline_asm stm32l0xx_ll_usart.h:3639:22:LL_USART_TransmitData9 16 static -main.c:135:5:main 32 static -main.c:316:6:SystemClock_Config 8 static -main.c:369:13:MX_I2C1_Init 72 static -main.c:432:13:MX_IWDG_Init 8 static -main.c:462:13:MX_TIM21_Init 24 static -main.c:501:13:MX_USART2_UART_Init 72 static -main.c:586:13:MX_GPIO_Init 8 static -main.c:595:6:USART2_TX_Buffer 24 static,ignoring_inline_asm -main.c:606:8:uart_disable_interrupts 8 static -main.c:615:8:uart_enable_interrupts 8 static -main.c:624:8:modbus_slave_callback 32 static -main.c:709:8:modbus_transmit_function 16 static -main.c:721:6:Error_Handler 8 static,ignoring_inline_asm +main.c:129:8:sht4x_i2c_transmit 32 static +main.c:134:8:sht4x_i2c_receive 32 static +main.c:139:9:sensirion_crc8_calculate 16 static +main.c:144:8:sht4x_disable_interrupts 8 static +main.c:149:8:sht4x_enable_interrupts 8 static +main.c:154:8:ltr329_i2c_transmit 32 static +main.c:158:8:ltr329_i2c_receive 32 static +main.c:163:8:ltr329_disable_interrupts 8 static +main.c:168:8:ltr329_enable_interrupts 8 static +main.c:173:6:delay_ms 16 static +main.c:183:5:main 32 static +main.c:374:6:SystemClock_Config 8 static +main.c:427:13:MX_I2C1_Init 72 static +main.c:490:13:MX_IWDG_Init 8 static +main.c:520:13:MX_TIM21_Init 24 static +main.c:559:13:MX_USART2_UART_Init 72 static +main.c:644:13:MX_GPIO_Init 8 static +main.c:653:6:USART2_TX_Buffer 24 static,ignoring_inline_asm +main.c:664:8:uart_disable_interrupts 8 static +main.c:673:8:uart_enable_interrupts 8 static +main.c:682:8:modbus_slave_callback 32 static +main.c:839:8:modbus_transmit_function 16 static +main.c:851:6:Error_Handler 8 static,ignoring_inline_asm diff --git a/fw/Debug/Core/Src/modbus.d b/fw/Debug/Core/Src/modbus.d deleted file mode 100644 index 0071433..0000000 --- a/fw/Debug/Core/Src/modbus.d +++ /dev/null @@ -1,3 +0,0 @@ -Core/Src/modbus.o: ../Core/Src/modbus.c ../Core/Inc/modbus.h - -../Core/Inc/modbus.h: diff --git a/fw/Debug/Core/Src/modbus.o b/fw/Debug/Core/Src/modbus.o deleted file mode 100644 index cf2f3fa..0000000 Binary files a/fw/Debug/Core/Src/modbus.o and /dev/null differ diff --git a/fw/Debug/Core/Src/sht4x.d b/fw/Debug/Core/Src/sht4x.d deleted file mode 100644 index 90a7801..0000000 --- a/fw/Debug/Core/Src/sht4x.d +++ /dev/null @@ -1,83 +0,0 @@ -Core/Src/sht4x.o: ../Core/Src/sht4x.c ../Core/Inc/sht4x.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h \ - ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l0xx.h \ - ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l031xx.h \ - ../Drivers/CMSIS/Include/core_cm0plus.h \ - ../Drivers/CMSIS/Include/cmsis_version.h \ - ../Drivers/CMSIS/Include/cmsis_compiler.h \ - ../Drivers/CMSIS/Include/cmsis_gcc.h \ - ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h \ - ../Core/Inc/i2c.h ../Core/Inc/crc8.h ../Core/Inc/main.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_iwdg.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_crs.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_rcc.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_bus.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_system.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_exti.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_cortex.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_pwr.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_dma.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_tim.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_usart.h \ - ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_gpio.h \ - ../Core/Inc/sht4x.h ../Core/Inc/ltr329.h ../Core/Inc/modbus.h \ - ../Core/Inc/config.h - -../Core/Inc/sht4x.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h: - -../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l0xx.h: - -../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l031xx.h: - -../Drivers/CMSIS/Include/core_cm0plus.h: - -../Drivers/CMSIS/Include/cmsis_version.h: - -../Drivers/CMSIS/Include/cmsis_compiler.h: - -../Drivers/CMSIS/Include/cmsis_gcc.h: - -../Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h: - -../Core/Inc/i2c.h: - -../Core/Inc/crc8.h: - -../Core/Inc/main.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_iwdg.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_crs.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_rcc.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_bus.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_system.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_exti.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_cortex.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_pwr.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_dma.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_tim.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_usart.h: - -../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_gpio.h: - -../Core/Inc/sht4x.h: - -../Core/Inc/ltr329.h: - -../Core/Inc/modbus.h: - -../Core/Inc/config.h: diff --git a/fw/Debug/Core/Src/sht4x.o b/fw/Debug/Core/Src/sht4x.o deleted file mode 100644 index f59a513..0000000 Binary files a/fw/Debug/Core/Src/sht4x.o and /dev/null differ diff --git a/fw/Debug/Core/Src/sht4x.su b/fw/Debug/Core/Src/sht4x.su index 4624627..e69de29 100644 --- a/fw/Debug/Core/Src/sht4x.su +++ b/fw/Debug/Core/Src/sht4x.su @@ -1,3 +0,0 @@ -sht4x.c:11:8:sht4x_send_cmd 16 static -sht4x.c:16:8:sht4x_read_data 16 static -sht4x.c:21:8:sht4x_measure 96 static diff --git a/fw/Debug/Core/Src/stm32l0xx_it.d b/fw/Debug/Core/Src/stm32l0xx_it.d index 1576e0d..e41573a 100644 --- a/fw/Debug/Core/Src/stm32l0xx_it.d +++ b/fw/Debug/Core/Src/stm32l0xx_it.d @@ -20,9 +20,12 @@ Core/Src/stm32l0xx_it.o: ../Core/Src/stm32l0xx_it.c ../Core/Inc/main.h \ ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_tim.h \ ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_usart.h \ ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_gpio.h \ - ../Core/Inc/i2c.h ../Core/Inc/sht4x.h ../Core/Inc/crc8.h \ - ../Core/Inc/ltr329.h ../Core/Inc/modbus.h ../Core/Inc/config.h \ - ../Core/Inc/stm32l0xx_it.h ../Core/Inc/modbus.h + ../Core/Inc/i2c.h \ + /home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/sht4x/sht4x.h \ + /home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329/ltr329.h \ + ../Core/Inc/i2c.h \ + /home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/modbus/modbus.h \ + ../Core/Inc/config.h ../Core/Inc/stm32l0xx_it.h ../Core/Inc/main.h: @@ -70,16 +73,14 @@ Core/Src/stm32l0xx_it.o: ../Core/Src/stm32l0xx_it.c ../Core/Inc/main.h \ ../Core/Inc/i2c.h: -../Core/Inc/sht4x.h: +/home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/sht4x/sht4x.h: -../Core/Inc/crc8.h: +/home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329/ltr329.h: -../Core/Inc/ltr329.h: +../Core/Inc/i2c.h: -../Core/Inc/modbus.h: +/home/david/VelesLabs/Smart\ Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/modbus/modbus.h: ../Core/Inc/config.h: ../Core/Inc/stm32l0xx_it.h: - -../Core/Inc/modbus.h: diff --git a/fw/Debug/Core/Src/stm32l0xx_it.o b/fw/Debug/Core/Src/stm32l0xx_it.o index d21bf48..87ca590 100644 Binary files a/fw/Debug/Core/Src/stm32l0xx_it.o and b/fw/Debug/Core/Src/stm32l0xx_it.o differ diff --git a/fw/Debug/Core/Src/subdir.mk b/fw/Debug/Core/Src/subdir.mk index 29a9eb4..4dbca5b 100644 --- a/fw/Debug/Core/Src/subdir.mk +++ b/fw/Debug/Core/Src/subdir.mk @@ -6,12 +6,8 @@ # Add inputs and outputs from these tool invocations to the build variables C_SRCS += \ ../Core/Src/config.c \ -../Core/Src/crc8.c \ ../Core/Src/i2c.c \ -../Core/Src/ltr329.c \ ../Core/Src/main.c \ -../Core/Src/modbus.c \ -../Core/Src/sht4x.c \ ../Core/Src/stm32l0xx_it.c \ ../Core/Src/syscalls.c \ ../Core/Src/sysmem.c \ @@ -19,12 +15,8 @@ C_SRCS += \ OBJS += \ ./Core/Src/config.o \ -./Core/Src/crc8.o \ ./Core/Src/i2c.o \ -./Core/Src/ltr329.o \ ./Core/Src/main.o \ -./Core/Src/modbus.o \ -./Core/Src/sht4x.o \ ./Core/Src/stm32l0xx_it.o \ ./Core/Src/syscalls.o \ ./Core/Src/sysmem.o \ @@ -32,12 +24,8 @@ OBJS += \ C_DEPS += \ ./Core/Src/config.d \ -./Core/Src/crc8.d \ ./Core/Src/i2c.d \ -./Core/Src/ltr329.d \ ./Core/Src/main.d \ -./Core/Src/modbus.d \ -./Core/Src/sht4x.d \ ./Core/Src/stm32l0xx_it.d \ ./Core/Src/syscalls.d \ ./Core/Src/sysmem.d \ @@ -46,12 +34,12 @@ C_DEPS += \ # Each subdirectory must supply rules for building sources it contributes Core/Src/%.o: ../Core/Src/%.c Core/Src/subdir.mk - arm-none-eabi-gcc "$<" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DSTM32L031xx -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DMSI_VALUE=2097000 -DHSI_VALUE=16000000 -DLSI_VALUE=37000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=0 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -c -I../Core/Inc -I../Drivers/STM32L0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32L0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" + arm-none-eabi-gcc "$<" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DSTM32L031xx -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DMSI_VALUE=2097000 -DHSI_VALUE=16000000 -DLSI_VALUE=37000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=0 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -c -I../Core/Inc -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/crc8" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/modbus" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/sht4x" -I../Drivers/STM32L0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32L0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" clean: clean-Core-2f-Src clean-Core-2f-Src: - -$(RM) ./Core/Src/config.d ./Core/Src/config.o ./Core/Src/crc8.d ./Core/Src/crc8.o ./Core/Src/i2c.d ./Core/Src/i2c.o ./Core/Src/ltr329.d ./Core/Src/ltr329.o ./Core/Src/main.d ./Core/Src/main.o ./Core/Src/modbus.d ./Core/Src/modbus.o ./Core/Src/sht4x.d ./Core/Src/sht4x.o ./Core/Src/stm32l0xx_it.d ./Core/Src/stm32l0xx_it.o ./Core/Src/syscalls.d ./Core/Src/syscalls.o ./Core/Src/sysmem.d ./Core/Src/sysmem.o ./Core/Src/system_stm32l0xx.d ./Core/Src/system_stm32l0xx.o + -$(RM) ./Core/Src/config.d ./Core/Src/config.o ./Core/Src/i2c.d ./Core/Src/i2c.o ./Core/Src/main.d ./Core/Src/main.o ./Core/Src/stm32l0xx_it.d ./Core/Src/stm32l0xx_it.o ./Core/Src/syscalls.d ./Core/Src/syscalls.o ./Core/Src/sysmem.d ./Core/Src/sysmem.o ./Core/Src/system_stm32l0xx.d ./Core/Src/system_stm32l0xx.o .PHONY: clean-Core-2f-Src diff --git a/fw/Debug/Core/Startup/subdir.mk b/fw/Debug/Core/Startup/subdir.mk index 7ce5abc..3157e5e 100644 --- a/fw/Debug/Core/Startup/subdir.mk +++ b/fw/Debug/Core/Startup/subdir.mk @@ -16,7 +16,7 @@ S_DEPS += \ # Each subdirectory must supply rules for building sources it contributes Core/Startup/%.o: ../Core/Startup/%.s Core/Startup/subdir.mk - arm-none-eabi-gcc -mcpu=cortex-m0plus -g3 -DDEBUG -c -x assembler-with-cpp -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" "$<" + arm-none-eabi-gcc -mcpu=cortex-m0plus -g3 -DDEBUG -c -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/crc8" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/modbus" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/sht4x" -x assembler-with-cpp -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" "$<" clean: clean-Core-2f-Startup diff --git a/fw/Debug/Drivers/STM32L0xx_HAL_Driver/Src/subdir.mk b/fw/Debug/Drivers/STM32L0xx_HAL_Driver/Src/subdir.mk index eab64fa..c05b913 100644 --- a/fw/Debug/Drivers/STM32L0xx_HAL_Driver/Src/subdir.mk +++ b/fw/Debug/Drivers/STM32L0xx_HAL_Driver/Src/subdir.mk @@ -40,7 +40,7 @@ C_DEPS += \ # Each subdirectory must supply rules for building sources it contributes Drivers/STM32L0xx_HAL_Driver/Src/%.o: ../Drivers/STM32L0xx_HAL_Driver/Src/%.c Drivers/STM32L0xx_HAL_Driver/Src/subdir.mk - arm-none-eabi-gcc "$<" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DSTM32L031xx -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DMSI_VALUE=2097000 -DHSI_VALUE=16000000 -DLSI_VALUE=37000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=0 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -c -I../Core/Inc -I../Drivers/STM32L0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32L0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" + arm-none-eabi-gcc "$<" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DSTM32L031xx -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DMSI_VALUE=2097000 -DHSI_VALUE=16000000 -DLSI_VALUE=37000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=0 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -c -I../Core/Inc -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/crc8" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/modbus" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/sht4x" -I../Drivers/STM32L0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32L0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" clean: clean-Drivers-2f-STM32L0xx_HAL_Driver-2f-Src diff --git a/fw/Debug/Libs/crc8/crc8.d b/fw/Debug/Libs/crc8/crc8.d new file mode 100644 index 0000000..92ecc9f --- /dev/null +++ b/fw/Debug/Libs/crc8/crc8.d @@ -0,0 +1,3 @@ +Libs/crc8/crc8.o: ../Libs/crc8/crc8.c ../Libs/crc8/crc8.h + +../Libs/crc8/crc8.h: diff --git a/fw/Debug/Libs/crc8/crc8.o b/fw/Debug/Libs/crc8/crc8.o new file mode 100644 index 0000000..3c85d66 Binary files /dev/null and b/fw/Debug/Libs/crc8/crc8.o differ diff --git a/fw/Debug/Libs/crc8/crc8.su b/fw/Debug/Libs/crc8/crc8.su new file mode 100644 index 0000000..a1c3f04 --- /dev/null +++ b/fw/Debug/Libs/crc8/crc8.su @@ -0,0 +1 @@ +crc8.c:14:9:crc8_calculate 24 static diff --git a/fw/Debug/Libs/crc8/subdir.mk b/fw/Debug/Libs/crc8/subdir.mk new file mode 100644 index 0000000..9a1b009 --- /dev/null +++ b/fw/Debug/Libs/crc8/subdir.mk @@ -0,0 +1,27 @@ +################################################################################ +# Automatically-generated file. Do not edit! +# Toolchain: GNU Tools for STM32 (9-2020-q2-update) +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +../Libs/crc8/crc8.c + +OBJS += \ +./Libs/crc8/crc8.o + +C_DEPS += \ +./Libs/crc8/crc8.d + + +# Each subdirectory must supply rules for building sources it contributes +Libs/crc8/%.o: ../Libs/crc8/%.c Libs/crc8/subdir.mk + arm-none-eabi-gcc "$<" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DSTM32L031xx -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DMSI_VALUE=2097000 -DHSI_VALUE=16000000 -DLSI_VALUE=37000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=0 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -c -I../Core/Inc -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/crc8" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/modbus" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/sht4x" -I../Drivers/STM32L0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32L0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" + +clean: clean-Libs-2f-crc8 + +clean-Libs-2f-crc8: + -$(RM) ./Libs/crc8/crc8.d ./Libs/crc8/crc8.o + +.PHONY: clean-Libs-2f-crc8 + diff --git a/fw/Debug/Libs/ltr329/ltr329.d b/fw/Debug/Libs/ltr329/ltr329.d new file mode 100644 index 0000000..ae97e45 --- /dev/null +++ b/fw/Debug/Libs/ltr329/ltr329.d @@ -0,0 +1,33 @@ +Libs/ltr329/ltr329.o: ../Libs/ltr329/ltr329.c ../Libs/ltr329/ltr329.h \ + ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h \ + ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l0xx.h \ + ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l031xx.h \ + ../Drivers/CMSIS/Include/core_cm0plus.h \ + ../Drivers/CMSIS/Include/cmsis_version.h \ + ../Drivers/CMSIS/Include/cmsis_compiler.h \ + ../Drivers/CMSIS/Include/cmsis_gcc.h \ + ../Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h \ + ../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h \ + ../Core/Inc/i2c.h + +../Libs/ltr329/ltr329.h: + +../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h: + +../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l0xx.h: + +../Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l031xx.h: + +../Drivers/CMSIS/Include/core_cm0plus.h: + +../Drivers/CMSIS/Include/cmsis_version.h: + +../Drivers/CMSIS/Include/cmsis_compiler.h: + +../Drivers/CMSIS/Include/cmsis_gcc.h: + +../Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h: + +../Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h: + +../Core/Inc/i2c.h: diff --git a/fw/Debug/Libs/ltr329/ltr329.o b/fw/Debug/Libs/ltr329/ltr329.o new file mode 100644 index 0000000..ed029cd Binary files /dev/null and b/fw/Debug/Libs/ltr329/ltr329.o differ diff --git a/fw/Debug/Libs/ltr329/ltr329.su b/fw/Debug/Libs/ltr329/ltr329.su new file mode 100644 index 0000000..39157f3 --- /dev/null +++ b/fw/Debug/Libs/ltr329/ltr329.su @@ -0,0 +1,8 @@ +ltr329.c:22:15:ltr329_read_register 40 static +ltr329.c:50:15:ltr329_write_register 32 static +ltr329.c:68:8:ltr329_write_settings 32 static +ltr329.c:87:8:ltr329_read_settings 48 static +ltr329.c:120:8:ltr329_sw_reset 24 static +ltr329.c:132:8:ltr329_measure 24 static +ltr329.c:162:8:ltr329_read_status_register 40 static +ltr329.c:200:8:ltr329_read_device_info 32 static diff --git a/fw/Debug/Libs/ltr329/subdir.mk b/fw/Debug/Libs/ltr329/subdir.mk new file mode 100644 index 0000000..f7ed346 --- /dev/null +++ b/fw/Debug/Libs/ltr329/subdir.mk @@ -0,0 +1,27 @@ +################################################################################ +# Automatically-generated file. Do not edit! +# Toolchain: GNU Tools for STM32 (9-2020-q2-update) +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +../Libs/ltr329/ltr329.c + +OBJS += \ +./Libs/ltr329/ltr329.o + +C_DEPS += \ +./Libs/ltr329/ltr329.d + + +# Each subdirectory must supply rules for building sources it contributes +Libs/ltr329/%.o: ../Libs/ltr329/%.c Libs/ltr329/subdir.mk + arm-none-eabi-gcc "$<" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DSTM32L031xx -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DMSI_VALUE=2097000 -DHSI_VALUE=16000000 -DLSI_VALUE=37000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=0 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -c -I../Core/Inc -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/crc8" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/modbus" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/sht4x" -I../Drivers/STM32L0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32L0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" + +clean: clean-Libs-2f-ltr329 + +clean-Libs-2f-ltr329: + -$(RM) ./Libs/ltr329/ltr329.d ./Libs/ltr329/ltr329.o + +.PHONY: clean-Libs-2f-ltr329 + diff --git a/fw/Debug/Libs/modbus/modbus.d b/fw/Debug/Libs/modbus/modbus.d new file mode 100644 index 0000000..40756b6 --- /dev/null +++ b/fw/Debug/Libs/modbus/modbus.d @@ -0,0 +1,3 @@ +Libs/modbus/modbus.o: ../Libs/modbus/modbus.c ../Libs/modbus/modbus.h + +../Libs/modbus/modbus.h: diff --git a/fw/Debug/Libs/modbus/modbus.o b/fw/Debug/Libs/modbus/modbus.o new file mode 100644 index 0000000..ad4720a Binary files /dev/null and b/fw/Debug/Libs/modbus/modbus.o differ diff --git a/fw/Debug/Libs/modbus/modbus.su b/fw/Debug/Libs/modbus/modbus.su new file mode 100644 index 0000000..aea08e5 --- /dev/null +++ b/fw/Debug/Libs/modbus/modbus.su @@ -0,0 +1,8 @@ +modbus.c:33:10:modbus_CRC16 32 static +modbus.c:57:16:modbus_fill_device_id_objects 40 static +modbus.c:107:15:modbus_transaction_to_buffer 56 static +modbus.c:170:15:modbus_process_device_id_request 32 static +modbus.c:217:15:modbus_process_read_write_request 40 static +modbus.c:341:8:modbus_slave_set_address 16 static +modbus.c:352:8:modbus_slave_process_msg 312 static +modbus.c:408:8:modbus_slave_init_device_id 16 static diff --git a/fw/Debug/Libs/modbus/subdir.mk b/fw/Debug/Libs/modbus/subdir.mk new file mode 100644 index 0000000..c86d040 --- /dev/null +++ b/fw/Debug/Libs/modbus/subdir.mk @@ -0,0 +1,27 @@ +################################################################################ +# Automatically-generated file. Do not edit! +# Toolchain: GNU Tools for STM32 (9-2020-q2-update) +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +../Libs/modbus/modbus.c + +OBJS += \ +./Libs/modbus/modbus.o + +C_DEPS += \ +./Libs/modbus/modbus.d + + +# Each subdirectory must supply rules for building sources it contributes +Libs/modbus/%.o: ../Libs/modbus/%.c Libs/modbus/subdir.mk + arm-none-eabi-gcc "$<" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DSTM32L031xx -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DMSI_VALUE=2097000 -DHSI_VALUE=16000000 -DLSI_VALUE=37000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=0 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -c -I../Core/Inc -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/crc8" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/modbus" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/sht4x" -I../Drivers/STM32L0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32L0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" + +clean: clean-Libs-2f-modbus + +clean-Libs-2f-modbus: + -$(RM) ./Libs/modbus/modbus.d ./Libs/modbus/modbus.o + +.PHONY: clean-Libs-2f-modbus + diff --git a/fw/Debug/Libs/sht4x/sht4x.d b/fw/Debug/Libs/sht4x/sht4x.d new file mode 100644 index 0000000..440aeb5 --- /dev/null +++ b/fw/Debug/Libs/sht4x/sht4x.d @@ -0,0 +1,3 @@ +Libs/sht4x/sht4x.o: ../Libs/sht4x/sht4x.c ../Libs/sht4x/sht4x.h + +../Libs/sht4x/sht4x.h: diff --git a/fw/Debug/Libs/sht4x/sht4x.o b/fw/Debug/Libs/sht4x/sht4x.o new file mode 100644 index 0000000..6ebbaf7 Binary files /dev/null and b/fw/Debug/Libs/sht4x/sht4x.o differ diff --git a/fw/Debug/Libs/sht4x/sht4x.su b/fw/Debug/Libs/sht4x/sht4x.su new file mode 100644 index 0000000..29401c8 --- /dev/null +++ b/fw/Debug/Libs/sht4x/sht4x.su @@ -0,0 +1,3 @@ +sht4x.c:29:8:sht4x_send_cmd 16 static +sht4x.c:34:8:sht4x_read_data 16 static +sht4x.c:39:8:sht4x_measure 96 static diff --git a/fw/Debug/Libs/sht4x/subdir.mk b/fw/Debug/Libs/sht4x/subdir.mk new file mode 100644 index 0000000..930dfd3 --- /dev/null +++ b/fw/Debug/Libs/sht4x/subdir.mk @@ -0,0 +1,27 @@ +################################################################################ +# Automatically-generated file. Do not edit! +# Toolchain: GNU Tools for STM32 (9-2020-q2-update) +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +../Libs/sht4x/sht4x.c + +OBJS += \ +./Libs/sht4x/sht4x.o + +C_DEPS += \ +./Libs/sht4x/sht4x.d + + +# Each subdirectory must supply rules for building sources it contributes +Libs/sht4x/%.o: ../Libs/sht4x/%.c Libs/sht4x/subdir.mk + arm-none-eabi-gcc "$<" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DSTM32L031xx -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DMSI_VALUE=2097000 -DHSI_VALUE=16000000 -DLSI_VALUE=37000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=0 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -c -I../Core/Inc -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/crc8" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/ltr329" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/modbus" -I"/home/david/VelesLabs/Smart Household/wired_sensors/RHT_Wired_Sensor/fw/Libs/sht4x" -I../Drivers/STM32L0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32L0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" + +clean: clean-Libs-2f-sht4x + +clean-Libs-2f-sht4x: + -$(RM) ./Libs/sht4x/sht4x.d ./Libs/sht4x/sht4x.o + +.PHONY: clean-Libs-2f-sht4x + diff --git a/fw/Debug/makefile b/fw/Debug/makefile index b242be0..c140656 100644 --- a/fw/Debug/makefile +++ b/fw/Debug/makefile @@ -9,6 +9,10 @@ RM := rm -rf # All of the sources participating in the build are defined here -include sources.mk +-include Libs/sht4x/subdir.mk +-include Libs/modbus/subdir.mk +-include Libs/ltr329/subdir.mk +-include Libs/crc8/subdir.mk -include Drivers/STM32L0xx_HAL_Driver/Src/subdir.mk -include Core/Startup/subdir.mk -include Core/Src/subdir.mk diff --git a/fw/Debug/objects.list b/fw/Debug/objects.list index b27f206..e5ca551 100644 --- a/fw/Debug/objects.list +++ b/fw/Debug/objects.list @@ -1,10 +1,6 @@ "./Core/Src/config.o" -"./Core/Src/crc8.o" "./Core/Src/i2c.o" -"./Core/Src/ltr329.o" "./Core/Src/main.o" -"./Core/Src/modbus.o" -"./Core/Src/sht4x.o" "./Core/Src/stm32l0xx_it.o" "./Core/Src/syscalls.o" "./Core/Src/sysmem.o" @@ -19,3 +15,7 @@ "./Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_tim.o" "./Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_usart.o" "./Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_utils.o" +"./Libs/crc8/crc8.o" +"./Libs/ltr329/ltr329.o" +"./Libs/modbus/modbus.o" +"./Libs/sht4x/sht4x.o" diff --git a/fw/Debug/rht_wired_sensor.bin b/fw/Debug/rht_wired_sensor.bin index 19602bb..aba9358 100755 Binary files a/fw/Debug/rht_wired_sensor.bin and b/fw/Debug/rht_wired_sensor.bin differ diff --git a/fw/Debug/rht_wired_sensor.elf b/fw/Debug/rht_wired_sensor.elf index f4755bc..8c0ab7b 100755 Binary files a/fw/Debug/rht_wired_sensor.elf and b/fw/Debug/rht_wired_sensor.elf differ diff --git a/fw/Debug/rht_wired_sensor.list b/fw/Debug/rht_wired_sensor.list index 90472dc..b915acb 100644 --- a/fw/Debug/rht_wired_sensor.list +++ b/fw/Debug/rht_wired_sensor.list @@ -5,45 +5,45 @@ Sections: Idx Name Size VMA LMA File off Algn 0 .isr_vector 000000c0 08000000 08000000 00010000 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA - 1 .text 00003b08 080000c0 080000c0 000100c0 2**2 + 1 .text 00003e98 080000c0 080000c0 000100c0 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE - 2 .rodata 000000f4 08003bc8 08003bc8 00013bc8 2**2 + 2 .rodata 00000148 08003f58 08003f58 00013f58 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA - 3 .ARM.extab 00000000 08003cbc 08003cbc 00020008 2**0 + 3 .ARM.extab 00000000 080040a0 080040a0 00020008 2**0 CONTENTS - 4 .ARM 00000000 08003cbc 08003cbc 00020008 2**0 + 4 .ARM 00000000 080040a0 080040a0 00020008 2**0 CONTENTS - 5 .preinit_array 00000000 08003cbc 08003cbc 00020008 2**0 + 5 .preinit_array 00000000 080040a0 080040a0 00020008 2**0 CONTENTS, ALLOC, LOAD, DATA - 6 .init_array 00000004 08003cbc 08003cbc 00013cbc 2**2 + 6 .init_array 00000004 080040a0 080040a0 000140a0 2**2 CONTENTS, ALLOC, LOAD, DATA - 7 .fini_array 00000004 08003cc0 08003cc0 00013cc0 2**2 + 7 .fini_array 00000004 080040a4 080040a4 000140a4 2**2 CONTENTS, ALLOC, LOAD, DATA - 8 .data 00000008 20000000 08003cc4 00020000 2**2 + 8 .data 00000008 20000000 080040a8 00020000 2**2 CONTENTS, ALLOC, LOAD, DATA - 9 .bss 0000017c 20000008 08003ccc 00020008 2**2 + 9 .bss 00000174 20000008 080040b0 00020008 2**2 ALLOC - 10 ._user_heap_stack 00000604 20000184 08003ccc 00020184 2**0 + 10 ._user_heap_stack 00000604 2000017c 080040b0 0002017c 2**0 ALLOC 11 .ARM.attributes 00000028 00000000 00000000 00020008 2**0 CONTENTS, READONLY - 12 .debug_info 0000a894 00000000 00000000 00020030 2**0 + 12 .debug_info 00009636 00000000 00000000 00020030 2**0 CONTENTS, READONLY, DEBUGGING, OCTETS - 13 .debug_abbrev 00001f3c 00000000 00000000 0002a8c4 2**0 + 13 .debug_abbrev 00001d62 00000000 00000000 00029666 2**0 CONTENTS, READONLY, DEBUGGING, OCTETS - 14 .debug_aranges 00000988 00000000 00000000 0002c800 2**3 + 14 .debug_aranges 000009d8 00000000 00000000 0002b3c8 2**3 CONTENTS, READONLY, DEBUGGING, OCTETS - 15 .debug_ranges 00000890 00000000 00000000 0002d188 2**3 + 15 .debug_ranges 000008e0 00000000 00000000 0002bda0 2**3 CONTENTS, READONLY, DEBUGGING, OCTETS - 16 .debug_macro 0000dc07 00000000 00000000 0002da18 2**0 + 16 .debug_macro 0000d7a8 00000000 00000000 0002c680 2**0 CONTENTS, READONLY, DEBUGGING, OCTETS - 17 .debug_line 00007bf1 00000000 00000000 0003b61f 2**0 + 17 .debug_line 000079e5 00000000 00000000 00039e28 2**0 CONTENTS, READONLY, DEBUGGING, OCTETS - 18 .debug_str 00044c4f 00000000 00000000 00043210 2**0 + 18 .debug_str 00044d2a 00000000 00000000 0004180d 2**0 CONTENTS, READONLY, DEBUGGING, OCTETS - 19 .comment 00000053 00000000 00000000 00087e5f 2**0 + 19 .comment 00000053 00000000 00000000 00086537 2**0 CONTENTS, READONLY - 20 .debug_frame 000020e4 00000000 00000000 00087eb4 2**2 + 20 .debug_frame 00002214 00000000 00000000 0008658c 2**2 CONTENTS, READONLY, DEBUGGING, OCTETS Disassembly of section .text: @@ -65,7 +65,7 @@ Disassembly of section .text: 80000da: bd10 pop {r4, pc} 80000dc: 20000008 .word 0x20000008 80000e0: 00000000 .word 0x00000000 - 80000e4: 08003bb0 .word 0x08003bb0 + 80000e4: 08003f40 .word 0x08003f40 080000e8 : 80000e8: 4b04 ldr r3, [pc, #16] ; (80000fc ) @@ -80,7 +80,7 @@ Disassembly of section .text: 80000fa: 46c0 nop ; (mov r8, r8) 80000fc: 00000000 .word 0x00000000 8000100: 2000000c .word 0x2000000c - 8000104: 08003bb0 .word 0x08003bb0 + 8000104: 08003f40 .word 0x08003f40 08000108 : 8000108: 2300 movs r3, #0 @@ -486,9857 +486,10456 @@ int8_t config_read(config_t *config) 8000408: af00 add r7, sp, #0 800040a: 6078 str r0, [r7, #4] config->modbus_addr = *(uint16_t *) (CONFIG_EEPROM_ADDR_MODBUS_ADDR); - 800040c: 4b1d ldr r3, [pc, #116] ; (8000484 ) + 800040c: 4b0a ldr r3, [pc, #40] ; (8000438 ) 800040e: 881a ldrh r2, [r3, #0] 8000410: 687b ldr r3, [r7, #4] - 8000412: 819a strh r2, [r3, #12] + 8000412: 809a strh r2, [r3, #4] config->baudrate_index = *(uint16_t *) (CONFIG_EEPROM_ADDR_BAUDRATE_INDEX); - 8000414: 4b1c ldr r3, [pc, #112] ; (8000488 ) + 8000414: 4b09 ldr r3, [pc, #36] ; (800043c ) 8000416: 881b ldrh r3, [r3, #0] 8000418: 001a movs r2, r3 800041a: 687b ldr r3, [r7, #4] - 800041c: 611a str r2, [r3, #16] - config->led_on = *(uint16_t *) (CONFIG_EEPROM_ADDR_LED_ON); - 800041e: 4b1b ldr r3, [pc, #108] ; (800048c ) - 8000420: 881b ldrh r3, [r3, #0] - 8000422: b2da uxtb r2, r3 - 8000424: 687b ldr r3, [r7, #4] - 8000426: 701a strb r2, [r3, #0] - config->led_brightness = *(uint16_t *) (CONFIG_EEPROM_ADDR_LED_BRIGHTNESS); - 8000428: 4b19 ldr r3, [pc, #100] ; (8000490 ) - 800042a: 881a ldrh r2, [r3, #0] - 800042c: 687b ldr r3, [r7, #4] - 800042e: 805a strh r2, [r3, #2] - config->led_smooth = *(uint16_t *) (CONFIG_EEPROM_ADDR_LED_SMOOTH); - 8000430: 4b18 ldr r3, [pc, #96] ; (8000494 ) - 8000432: 881b ldrh r3, [r3, #0] - 8000434: b2da uxtb r2, r3 - 8000436: 687b ldr r3, [r7, #4] - 8000438: 711a strb r2, [r3, #4] - config->led_co2_alert_limit1 = *(uint16_t *) (CONFIG_EEPROM_ADDR_LED_ALERT1); - 800043a: 4b17 ldr r3, [pc, #92] ; (8000498 ) - 800043c: 881a ldrh r2, [r3, #0] - 800043e: 687b ldr r3, [r7, #4] - 8000440: 80da strh r2, [r3, #6] - config->led_co2_alert_limit2 = *(uint16_t *) (CONFIG_EEPROM_ADDR_LED_ALERT2); - 8000442: 4b16 ldr r3, [pc, #88] ; (800049c ) - 8000444: 881a ldrh r2, [r3, #0] - 8000446: 687b ldr r3, [r7, #4] - 8000448: 811a strh r2, [r3, #8] - config->scd4x_t_offset = *(int16_t *) (CONFIG_EEPROM_ADDR_SCD4x_T_OFFSET); - 800044a: 4b15 ldr r3, [pc, #84] ; (80004a0 ) - 800044c: 2200 movs r2, #0 - 800044e: 5e9a ldrsh r2, [r3, r2] - 8000450: 687b ldr r3, [r7, #4] - 8000452: 815a strh r2, [r3, #10] - * LED ON - * LED SMOOTH - * SCD4x T OFFSET + 800041c: 609a str r2, [r3, #8] + + /* Check if the EEPROM is initialized - do not check: * BAUDRATE INDEX * those can be 0 */ - if ((config->modbus_addr == EEPROM_EMPTY_BYTE) || - 8000454: 687b ldr r3, [r7, #4] - 8000456: 899b ldrh r3, [r3, #12] - 8000458: 2b00 cmp r3, #0 - 800045a: d00b beq.n 8000474 - (config->led_co2_alert_limit1 == EEPROM_EMPTY_BYTE) || - 800045c: 687b ldr r3, [r7, #4] - 800045e: 88db ldrh r3, [r3, #6] - if ((config->modbus_addr == EEPROM_EMPTY_BYTE) || - 8000460: 2b00 cmp r3, #0 - 8000462: d007 beq.n 8000474 - (config->led_co2_alert_limit2 == EEPROM_EMPTY_BYTE) || - 8000464: 687b ldr r3, [r7, #4] - 8000466: 891b ldrh r3, [r3, #8] - (config->led_co2_alert_limit1 == EEPROM_EMPTY_BYTE) || - 8000468: 2b00 cmp r3, #0 - 800046a: d003 beq.n 8000474 - (config->led_brightness == EEPROM_EMPTY_BYTE)) - 800046c: 687b ldr r3, [r7, #4] - 800046e: 885b ldrh r3, [r3, #2] - (config->led_co2_alert_limit2 == EEPROM_EMPTY_BYTE) || - 8000470: 2b00 cmp r3, #0 - 8000472: d102 bne.n 800047a + if (config->modbus_addr == EEPROM_EMPTY_BYTE) + 800041e: 687b ldr r3, [r7, #4] + 8000420: 889b ldrh r3, [r3, #4] + 8000422: 2b00 cmp r3, #0 + 8000424: d102 bne.n 800042c { return CONFIG_ERROR; - 8000474: 2301 movs r3, #1 - 8000476: 425b negs r3, r3 - 8000478: e000 b.n 800047c + 8000426: 2301 movs r3, #1 + 8000428: 425b negs r3, r3 + 800042a: e000 b.n 800042e } return CONFIG_OK; - 800047a: 2300 movs r3, #0 + 800042c: 2300 movs r3, #0 } - 800047c: 0018 movs r0, r3 - 800047e: 46bd mov sp, r7 - 8000480: b002 add sp, #8 - 8000482: bd80 pop {r7, pc} - 8000484: 08080000 .word 0x08080000 - 8000488: 08080002 .word 0x08080002 - 800048c: 08080004 .word 0x08080004 - 8000490: 08080006 .word 0x08080006 - 8000494: 08080008 .word 0x08080008 - 8000498: 0808000a .word 0x0808000a - 800049c: 0808000c .word 0x0808000c - 80004a0: 0808000e .word 0x0808000e + 800042e: 0018 movs r0, r3 + 8000430: 46bd mov sp, r7 + 8000432: b002 add sp, #8 + 8000434: bd80 pop {r7, pc} + 8000436: 46c0 nop ; (mov r8, r8) + 8000438: 08080000 .word 0x08080000 + 800043c: 08080002 .word 0x08080002 -080004a4 : +08000440 : int8_t config_write(config_t *config) { - 80004a4: b580 push {r7, lr} - 80004a6: b082 sub sp, #8 - 80004a8: af00 add r7, sp, #0 - 80004aa: 6078 str r0, [r7, #4] + 8000440: b580 push {r7, lr} + 8000442: b082 sub sp, #8 + 8000444: af00 add r7, sp, #0 + 8000446: 6078 str r0, [r7, #4] /* Unlock the EEPROM */ if (eeprom_unlock() != EEPROM_OK) - 80004ac: f000 f8cc bl 8000648 - 80004b0: 1e03 subs r3, r0, #0 - 80004b2: d002 beq.n 80004ba + 8000448: f000 f876 bl 8000538 + 800044c: 1e03 subs r3, r0, #0 + 800044e: d002 beq.n 8000456 { return EEPROM_UNLOCK_ERROR; - 80004b4: 2302 movs r3, #2 - 80004b6: 425b negs r3, r3 - 80004b8: e070 b.n 800059c + 8000450: 2302 movs r3, #2 + 8000452: 425b negs r3, r3 + 8000454: e026 b.n 80004a4 } /* Reset the ERASE and DATA bits in the FLASH_PECR register to disable any residual erase */ FLASH->PECR = FLASH->PECR & ~(FLASH_PECR_ERASE | FLASH_PECR_DATA); - 80004ba: 4b3a ldr r3, [pc, #232] ; (80005a4 ) - 80004bc: 685a ldr r2, [r3, #4] - 80004be: 4b39 ldr r3, [pc, #228] ; (80005a4 ) - 80004c0: 4939 ldr r1, [pc, #228] ; (80005a8 ) - 80004c2: 400a ands r2, r1 - 80004c4: 605a str r2, [r3, #4] + 8000456: 4b15 ldr r3, [pc, #84] ; (80004ac ) + 8000458: 685a ldr r2, [r3, #4] + 800045a: 4b14 ldr r3, [pc, #80] ; (80004ac ) + 800045c: 4914 ldr r1, [pc, #80] ; (80004b0 ) + 800045e: 400a ands r2, r1 + 8000460: 605a str r2, [r3, #4] /* Write MODBUS ADDRESS */ if (eeprom_program_halfword(CONFIG_EEPROM_ADDR_MODBUS_ADDR, config->modbus_addr) != EEPROM_OK) - 80004c6: 687b ldr r3, [r7, #4] - 80004c8: 899b ldrh r3, [r3, #12] - 80004ca: 4a38 ldr r2, [pc, #224] ; (80005ac ) - 80004cc: 0019 movs r1, r3 - 80004ce: 0010 movs r0, r2 - 80004d0: f000 f928 bl 8000724 - 80004d4: 1e03 subs r3, r0, #0 - 80004d6: d002 beq.n 80004de + 8000462: 687b ldr r3, [r7, #4] + 8000464: 889b ldrh r3, [r3, #4] + 8000466: 4a13 ldr r2, [pc, #76] ; (80004b4 ) + 8000468: 0019 movs r1, r3 + 800046a: 0010 movs r0, r2 + 800046c: f000 f8aa bl 80005c4 + 8000470: 1e03 subs r3, r0, #0 + 8000472: d002 beq.n 800047a { return EEPROM_WRITE_ERROR; - 80004d8: 2304 movs r3, #4 - 80004da: 425b negs r3, r3 - 80004dc: e05e b.n 800059c + 8000474: 2304 movs r3, #4 + 8000476: 425b negs r3, r3 + 8000478: e014 b.n 80004a4 } + /* Write BAUDRATE */ if (eeprom_program_halfword(CONFIG_EEPROM_ADDR_BAUDRATE_INDEX, config->baudrate_index) != EEPROM_OK) - 80004de: 687b ldr r3, [r7, #4] - 80004e0: 691b ldr r3, [r3, #16] - 80004e2: b29b uxth r3, r3 - 80004e4: 4a32 ldr r2, [pc, #200] ; (80005b0 ) - 80004e6: 0019 movs r1, r3 - 80004e8: 0010 movs r0, r2 - 80004ea: f000 f91b bl 8000724 - 80004ee: 1e03 subs r3, r0, #0 - 80004f0: d002 beq.n 80004f8 + 800047a: 687b ldr r3, [r7, #4] + 800047c: 689b ldr r3, [r3, #8] + 800047e: b29b uxth r3, r3 + 8000480: 4a0d ldr r2, [pc, #52] ; (80004b8 ) + 8000482: 0019 movs r1, r3 + 8000484: 0010 movs r0, r2 + 8000486: f000 f89d bl 80005c4 + 800048a: 1e03 subs r3, r0, #0 + 800048c: d002 beq.n 8000494 { return EEPROM_WRITE_ERROR; - 80004f2: 2304 movs r3, #4 - 80004f4: 425b negs r3, r3 - 80004f6: e051 b.n 800059c - } - - /* Write LED ON */ - if (eeprom_program_byte(CONFIG_EEPROM_ADDR_LED_ON, config->led_on) != EEPROM_OK) - 80004f8: 687b ldr r3, [r7, #4] - 80004fa: 781b ldrb r3, [r3, #0] - 80004fc: 4a2d ldr r2, [pc, #180] ; (80005b4 ) - 80004fe: 0019 movs r1, r3 - 8000500: 0010 movs r0, r2 - 8000502: f000 f8e7 bl 80006d4 - 8000506: 1e03 subs r3, r0, #0 - 8000508: d002 beq.n 8000510 - { - return EEPROM_WRITE_ERROR; - 800050a: 2304 movs r3, #4 - 800050c: 425b negs r3, r3 - 800050e: e045 b.n 800059c - } - - /* Write LED BRIGHTNESS */ - if (eeprom_program_halfword(CONFIG_EEPROM_ADDR_LED_BRIGHTNESS, config->led_brightness) != EEPROM_OK) - 8000510: 687b ldr r3, [r7, #4] - 8000512: 885b ldrh r3, [r3, #2] - 8000514: 4a28 ldr r2, [pc, #160] ; (80005b8 ) - 8000516: 0019 movs r1, r3 - 8000518: 0010 movs r0, r2 - 800051a: f000 f903 bl 8000724 - 800051e: 1e03 subs r3, r0, #0 - 8000520: d002 beq.n 8000528 - { - return EEPROM_WRITE_ERROR; - 8000522: 2304 movs r3, #4 - 8000524: 425b negs r3, r3 - 8000526: e039 b.n 800059c - } - - /* Write LED SMOOTH */ - if (eeprom_program_byte(CONFIG_EEPROM_ADDR_LED_SMOOTH, config->led_smooth) != EEPROM_OK) - 8000528: 687b ldr r3, [r7, #4] - 800052a: 791b ldrb r3, [r3, #4] - 800052c: 4a23 ldr r2, [pc, #140] ; (80005bc ) - 800052e: 0019 movs r1, r3 - 8000530: 0010 movs r0, r2 - 8000532: f000 f8cf bl 80006d4 - 8000536: 1e03 subs r3, r0, #0 - 8000538: d002 beq.n 8000540 - { - return EEPROM_WRITE_ERROR; - 800053a: 2304 movs r3, #4 - 800053c: 425b negs r3, r3 - 800053e: e02d b.n 800059c - } - - /* Write LED CO2 ALERT LIMIT 1 */ - if (eeprom_program_halfword(CONFIG_EEPROM_ADDR_LED_ALERT1, config->led_co2_alert_limit1) != EEPROM_OK) - 8000540: 687b ldr r3, [r7, #4] - 8000542: 88db ldrh r3, [r3, #6] - 8000544: 4a1e ldr r2, [pc, #120] ; (80005c0 ) - 8000546: 0019 movs r1, r3 - 8000548: 0010 movs r0, r2 - 800054a: f000 f8eb bl 8000724 - 800054e: 1e03 subs r3, r0, #0 - 8000550: d002 beq.n 8000558 - { - return EEPROM_WRITE_ERROR; - 8000552: 2304 movs r3, #4 - 8000554: 425b negs r3, r3 - 8000556: e021 b.n 800059c - } - - /* Write LED CO2 ALERT LIMIT 2 */ - if (eeprom_program_halfword(CONFIG_EEPROM_ADDR_LED_ALERT2, config->led_co2_alert_limit2) != EEPROM_OK) - 8000558: 687b ldr r3, [r7, #4] - 800055a: 891b ldrh r3, [r3, #8] - 800055c: 4a19 ldr r2, [pc, #100] ; (80005c4 ) - 800055e: 0019 movs r1, r3 - 8000560: 0010 movs r0, r2 - 8000562: f000 f8df bl 8000724 - 8000566: 1e03 subs r3, r0, #0 - 8000568: d002 beq.n 8000570 - { - return EEPROM_WRITE_ERROR; - 800056a: 2304 movs r3, #4 - 800056c: 425b negs r3, r3 - 800056e: e015 b.n 800059c - } - - /* Write LED SCD4x TEMPERATURE OFFSET */ - if (eeprom_program_halfword(CONFIG_EEPROM_ADDR_SCD4x_T_OFFSET, config->scd4x_t_offset) != EEPROM_OK) - 8000570: 687b ldr r3, [r7, #4] - 8000572: 220a movs r2, #10 - 8000574: 5e9b ldrsh r3, [r3, r2] - 8000576: b29b uxth r3, r3 - 8000578: 4a13 ldr r2, [pc, #76] ; (80005c8 ) - 800057a: 0019 movs r1, r3 - 800057c: 0010 movs r0, r2 - 800057e: f000 f8d1 bl 8000724 - 8000582: 1e03 subs r3, r0, #0 - 8000584: d002 beq.n 800058c - { - return EEPROM_WRITE_ERROR; - 8000586: 2304 movs r3, #4 - 8000588: 425b negs r3, r3 - 800058a: e007 b.n 800059c + 800048e: 2304 movs r3, #4 + 8000490: 425b negs r3, r3 + 8000492: e007 b.n 80004a4 } /* Lock EEPROM*/ if (eeprom_lock() != EEPROM_OK) - 800058c: f000 f81e bl 80005cc - 8000590: 1e03 subs r3, r0, #0 - 8000592: d002 beq.n 800059a + 8000494: f000 f812 bl 80004bc + 8000498: 1e03 subs r3, r0, #0 + 800049a: d002 beq.n 80004a2 { return EEPROM_LOCK_ERROR; - 8000594: 2303 movs r3, #3 - 8000596: 425b negs r3, r3 - 8000598: e000 b.n 800059c + 800049c: 2303 movs r3, #3 + 800049e: 425b negs r3, r3 + 80004a0: e000 b.n 80004a4 } return CONFIG_OK; - 800059a: 2300 movs r3, #0 + 80004a2: 2300 movs r3, #0 } - 800059c: 0018 movs r0, r3 - 800059e: 46bd mov sp, r7 - 80005a0: b002 add sp, #8 - 80005a2: bd80 pop {r7, pc} - 80005a4: 40022000 .word 0x40022000 - 80005a8: fffffdef .word 0xfffffdef - 80005ac: 08080000 .word 0x08080000 - 80005b0: 08080002 .word 0x08080002 - 80005b4: 08080004 .word 0x08080004 - 80005b8: 08080006 .word 0x08080006 - 80005bc: 08080008 .word 0x08080008 - 80005c0: 0808000a .word 0x0808000a - 80005c4: 0808000c .word 0x0808000c - 80005c8: 0808000e .word 0x0808000e + 80004a4: 0018 movs r0, r3 + 80004a6: 46bd mov sp, r7 + 80004a8: b002 add sp, #8 + 80004aa: bd80 pop {r7, pc} + 80004ac: 40022000 .word 0x40022000 + 80004b0: fffffdef .word 0xfffffdef + 80004b4: 08080000 .word 0x08080000 + 80004b8: 08080002 .word 0x08080002 -080005cc : +080004bc : static int8_t eeprom_lock(void) { - 80005cc: b580 push {r7, lr} - 80005ce: b084 sub sp, #16 - 80005d0: af00 add r7, sp, #0 + 80004bc: b580 push {r7, lr} + 80004be: b084 sub sp, #16 + 80004c0: af00 add r7, sp, #0 uint32_t tick_start = SysTick->VAL; - 80005d2: 4b19 ldr r3, [pc, #100] ; (8000638 ) - 80005d4: 689b ldr r3, [r3, #8] - 80005d6: 60bb str r3, [r7, #8] + 80004c2: 4b19 ldr r3, [pc, #100] ; (8000528 ) + 80004c4: 689b ldr r3, [r3, #8] + 80004c6: 60bb str r3, [r7, #8] while ((FLASH->SR & FLASH_SR_BSY) != 0) /* Wait for FLASH to be free */ - 80005d8: e017 b.n 800060a + 80004c8: e017 b.n 80004fa { /* Timeout test */ /* The maximum writing time is 3.94ms (half-word) */ uint32_t tick_last = SysTick->VAL; - 80005da: 4b17 ldr r3, [pc, #92] ; (8000638 ) - 80005dc: 689b ldr r3, [r3, #8] - 80005de: 607b str r3, [r7, #4] + 80004ca: 4b17 ldr r3, [pc, #92] ; (8000528 ) + 80004cc: 689b ldr r3, [r3, #8] + 80004ce: 607b str r3, [r7, #4] uint32_t tick_diff; if (tick_start <= tick_last) - 80005e0: 68ba ldr r2, [r7, #8] - 80005e2: 687b ldr r3, [r7, #4] - 80005e4: 429a cmp r2, r3 - 80005e6: d804 bhi.n 80005f2 + 80004d0: 68ba ldr r2, [r7, #8] + 80004d2: 687b ldr r3, [r7, #4] + 80004d4: 429a cmp r2, r3 + 80004d6: d804 bhi.n 80004e2 { tick_diff = tick_last - tick_start; - 80005e8: 687a ldr r2, [r7, #4] - 80005ea: 68bb ldr r3, [r7, #8] - 80005ec: 1ad3 subs r3, r2, r3 - 80005ee: 60fb str r3, [r7, #12] - 80005f0: e004 b.n 80005fc + 80004d8: 687a ldr r2, [r7, #4] + 80004da: 68bb ldr r3, [r7, #8] + 80004dc: 1ad3 subs r3, r2, r3 + 80004de: 60fb str r3, [r7, #12] + 80004e0: e004 b.n 80004ec } else { tick_diff = (0xFFFFFFFF - tick_last) + tick_start; - 80005f2: 68ba ldr r2, [r7, #8] - 80005f4: 687b ldr r3, [r7, #4] - 80005f6: 1ad3 subs r3, r2, r3 - 80005f8: 3b01 subs r3, #1 - 80005fa: 60fb str r3, [r7, #12] + 80004e2: 68ba ldr r2, [r7, #8] + 80004e4: 687b ldr r3, [r7, #4] + 80004e6: 1ad3 subs r3, r2, r3 + 80004e8: 3b01 subs r3, #1 + 80004ea: 60fb str r3, [r7, #12] } /* If the time difference is more than 5ms */ if (tick_diff >= (uint32_t)((uint32_t)SYSTICK_FREQ_HZ*(uint32_t)EEPROM_TIMEOUT_MAX_MS_INV)) - 80005fc: 68fb ldr r3, [r7, #12] - 80005fe: 4a0f ldr r2, [pc, #60] ; (800063c ) - 8000600: 4293 cmp r3, r2 - 8000602: d902 bls.n 800060a + 80004ec: 68fb ldr r3, [r7, #12] + 80004ee: 4a0f ldr r2, [pc, #60] ; (800052c ) + 80004f0: 4293 cmp r3, r2 + 80004f2: d902 bls.n 80004fa { return EEPROM_LOCK_ERROR; - 8000604: 2303 movs r3, #3 - 8000606: 425b negs r3, r3 - 8000608: e011 b.n 800062e + 80004f4: 2303 movs r3, #3 + 80004f6: 425b negs r3, r3 + 80004f8: e011 b.n 800051e while ((FLASH->SR & FLASH_SR_BSY) != 0) /* Wait for FLASH to be free */ - 800060a: 4b0d ldr r3, [pc, #52] ; (8000640 ) - 800060c: 699b ldr r3, [r3, #24] - 800060e: 2201 movs r2, #1 - 8000610: 4013 ands r3, r2 - 8000612: d1e2 bne.n 80005da + 80004fa: 4b0d ldr r3, [pc, #52] ; (8000530 ) + 80004fc: 699b ldr r3, [r3, #24] + 80004fe: 2201 movs r2, #1 + 8000500: 4013 ands r3, r2 + 8000502: d1e2 bne.n 80004ca } } FLASH->PECR = FLASH->PECR & ~(FLASH_PECR_ERRIE | FLASH_PECR_EOPIE); /* disable flash interrupts */ - 8000614: 4b0a ldr r3, [pc, #40] ; (8000640 ) - 8000616: 685a ldr r2, [r3, #4] - 8000618: 4b09 ldr r3, [pc, #36] ; (8000640 ) - 800061a: 490a ldr r1, [pc, #40] ; (8000644 ) - 800061c: 400a ands r2, r1 - 800061e: 605a str r2, [r3, #4] + 8000504: 4b0a ldr r3, [pc, #40] ; (8000530 ) + 8000506: 685a ldr r2, [r3, #4] + 8000508: 4b09 ldr r3, [pc, #36] ; (8000530 ) + 800050a: 490a ldr r1, [pc, #40] ; (8000534 ) + 800050c: 400a ands r2, r1 + 800050e: 605a str r2, [r3, #4] FLASH->PECR = FLASH->PECR | FLASH_PECR_PELOCK; /* Lock memory with PELOCK */ - 8000620: 4b07 ldr r3, [pc, #28] ; (8000640 ) - 8000622: 685a ldr r2, [r3, #4] - 8000624: 4b06 ldr r3, [pc, #24] ; (8000640 ) - 8000626: 2101 movs r1, #1 - 8000628: 430a orrs r2, r1 - 800062a: 605a str r2, [r3, #4] + 8000510: 4b07 ldr r3, [pc, #28] ; (8000530 ) + 8000512: 685a ldr r2, [r3, #4] + 8000514: 4b06 ldr r3, [pc, #24] ; (8000530 ) + 8000516: 2101 movs r1, #1 + 8000518: 430a orrs r2, r1 + 800051a: 605a str r2, [r3, #4] return EEPROM_OK; - 800062c: 2300 movs r3, #0 + 800051c: 2300 movs r3, #0 } - 800062e: 0018 movs r0, r3 - 8000630: 46bd mov sp, r7 - 8000632: b004 add sp, #16 - 8000634: bd80 pop {r7, pc} - 8000636: 46c0 nop ; (mov r8, r8) - 8000638: e000e010 .word 0xe000e010 - 800063c: 8f0d17ff .word 0x8f0d17ff - 8000640: 40022000 .word 0x40022000 - 8000644: fffcffff .word 0xfffcffff + 800051e: 0018 movs r0, r3 + 8000520: 46bd mov sp, r7 + 8000522: b004 add sp, #16 + 8000524: bd80 pop {r7, pc} + 8000526: 46c0 nop ; (mov r8, r8) + 8000528: e000e010 .word 0xe000e010 + 800052c: 8f0d17ff .word 0x8f0d17ff + 8000530: 40022000 .word 0x40022000 + 8000534: fffcffff .word 0xfffcffff -08000648 : +08000538 : static int8_t eeprom_unlock(void) { - 8000648: b580 push {r7, lr} - 800064a: b084 sub sp, #16 - 800064c: af00 add r7, sp, #0 + 8000538: b580 push {r7, lr} + 800053a: b084 sub sp, #16 + 800053c: af00 add r7, sp, #0 uint32_t tick_start = SysTick->VAL; - 800064e: 4b1c ldr r3, [pc, #112] ; (80006c0 ) - 8000650: 689b ldr r3, [r3, #8] - 8000652: 60bb str r3, [r7, #8] + 800053e: 4b1c ldr r3, [pc, #112] ; (80005b0 ) + 8000540: 689b ldr r3, [r3, #8] + 8000542: 60bb str r3, [r7, #8] while ((FLASH->SR & FLASH_SR_BSY) != 0) /* Wait for FLASH to be free */ - 8000654: e017 b.n 8000686 + 8000544: e017 b.n 8000576 { /* Timeout test */ /* The maximum writing time is 3.94ms (half-word) */ uint32_t tick_last = SysTick->VAL; - 8000656: 4b1a ldr r3, [pc, #104] ; (80006c0 ) - 8000658: 689b ldr r3, [r3, #8] - 800065a: 607b str r3, [r7, #4] + 8000546: 4b1a ldr r3, [pc, #104] ; (80005b0 ) + 8000548: 689b ldr r3, [r3, #8] + 800054a: 607b str r3, [r7, #4] uint32_t tick_diff; if (tick_start <= tick_last) - 800065c: 68ba ldr r2, [r7, #8] - 800065e: 687b ldr r3, [r7, #4] - 8000660: 429a cmp r2, r3 - 8000662: d804 bhi.n 800066e + 800054c: 68ba ldr r2, [r7, #8] + 800054e: 687b ldr r3, [r7, #4] + 8000550: 429a cmp r2, r3 + 8000552: d804 bhi.n 800055e { tick_diff = tick_last - tick_start; - 8000664: 687a ldr r2, [r7, #4] - 8000666: 68bb ldr r3, [r7, #8] - 8000668: 1ad3 subs r3, r2, r3 - 800066a: 60fb str r3, [r7, #12] - 800066c: e004 b.n 8000678 + 8000554: 687a ldr r2, [r7, #4] + 8000556: 68bb ldr r3, [r7, #8] + 8000558: 1ad3 subs r3, r2, r3 + 800055a: 60fb str r3, [r7, #12] + 800055c: e004 b.n 8000568 } else { tick_diff = (0xFFFFFFFF - tick_last) + tick_start; - 800066e: 68ba ldr r2, [r7, #8] - 8000670: 687b ldr r3, [r7, #4] - 8000672: 1ad3 subs r3, r2, r3 - 8000674: 3b01 subs r3, #1 - 8000676: 60fb str r3, [r7, #12] + 800055e: 68ba ldr r2, [r7, #8] + 8000560: 687b ldr r3, [r7, #4] + 8000562: 1ad3 subs r3, r2, r3 + 8000564: 3b01 subs r3, #1 + 8000566: 60fb str r3, [r7, #12] } /* If the time difference is more than 5ms */ if (tick_diff >= (uint32_t)((uint32_t)SYSTICK_FREQ_HZ*(uint32_t)EEPROM_TIMEOUT_MAX_MS_INV)) - 8000678: 68fb ldr r3, [r7, #12] - 800067a: 4a12 ldr r2, [pc, #72] ; (80006c4 ) - 800067c: 4293 cmp r3, r2 - 800067e: d902 bls.n 8000686 + 8000568: 68fb ldr r3, [r7, #12] + 800056a: 4a12 ldr r2, [pc, #72] ; (80005b4 ) + 800056c: 4293 cmp r3, r2 + 800056e: d902 bls.n 8000576 { return EEPROM_UNLOCK_ERROR; - 8000680: 2302 movs r3, #2 - 8000682: 425b negs r3, r3 - 8000684: e017 b.n 80006b6 + 8000570: 2302 movs r3, #2 + 8000572: 425b negs r3, r3 + 8000574: e017 b.n 80005a6 while ((FLASH->SR & FLASH_SR_BSY) != 0) /* Wait for FLASH to be free */ - 8000686: 4b10 ldr r3, [pc, #64] ; (80006c8 ) - 8000688: 699b ldr r3, [r3, #24] - 800068a: 2201 movs r2, #1 - 800068c: 4013 ands r3, r2 - 800068e: d1e2 bne.n 8000656 + 8000576: 4b10 ldr r3, [pc, #64] ; (80005b8 ) + 8000578: 699b ldr r3, [r3, #24] + 800057a: 2201 movs r2, #1 + 800057c: 4013 ands r3, r2 + 800057e: d1e2 bne.n 8000546 } } if ((FLASH->PECR & FLASH_PECR_PELOCK) != 0) /* If PELOCK is locked */ - 8000690: 4b0d ldr r3, [pc, #52] ; (80006c8 ) - 8000692: 685b ldr r3, [r3, #4] - 8000694: 2201 movs r2, #1 - 8000696: 4013 ands r3, r2 - 8000698: d005 beq.n 80006a6 + 8000580: 4b0d ldr r3, [pc, #52] ; (80005b8 ) + 8000582: 685b ldr r3, [r3, #4] + 8000584: 2201 movs r2, #1 + 8000586: 4013 ands r3, r2 + 8000588: d005 beq.n 8000596 { /* Unlock PELOCK */ FLASH->PEKEYR = FLASH_PEKEY1; /* PEKEY1 */ - 800069a: 4b0b ldr r3, [pc, #44] ; (80006c8 ) - 800069c: 4a0b ldr r2, [pc, #44] ; (80006cc ) - 800069e: 60da str r2, [r3, #12] + 800058a: 4b0b ldr r3, [pc, #44] ; (80005b8 ) + 800058c: 4a0b ldr r2, [pc, #44] ; (80005bc ) + 800058e: 60da str r2, [r3, #12] FLASH->PEKEYR = FLASH_PEKEY2; /* PEKEY2 */ - 80006a0: 4b09 ldr r3, [pc, #36] ; (80006c8 ) - 80006a2: 4a0b ldr r2, [pc, #44] ; (80006d0 ) - 80006a4: 60da str r2, [r3, #12] + 8000590: 4b09 ldr r3, [pc, #36] ; (80005b8 ) + 8000592: 4a0b ldr r2, [pc, #44] ; (80005c0 ) + 8000594: 60da str r2, [r3, #12] } FLASH->PECR = FLASH->PECR | (FLASH_PECR_ERRIE | FLASH_PECR_EOPIE); /* enable flash interrupts */ - 80006a6: 4b08 ldr r3, [pc, #32] ; (80006c8 ) - 80006a8: 685a ldr r2, [r3, #4] - 80006aa: 4b07 ldr r3, [pc, #28] ; (80006c8 ) - 80006ac: 21c0 movs r1, #192 ; 0xc0 - 80006ae: 0289 lsls r1, r1, #10 - 80006b0: 430a orrs r2, r1 - 80006b2: 605a str r2, [r3, #4] + 8000596: 4b08 ldr r3, [pc, #32] ; (80005b8 ) + 8000598: 685a ldr r2, [r3, #4] + 800059a: 4b07 ldr r3, [pc, #28] ; (80005b8 ) + 800059c: 21c0 movs r1, #192 ; 0xc0 + 800059e: 0289 lsls r1, r1, #10 + 80005a0: 430a orrs r2, r1 + 80005a2: 605a str r2, [r3, #4] return EEPROM_OK; - 80006b4: 2300 movs r3, #0 + 80005a4: 2300 movs r3, #0 } - 80006b6: 0018 movs r0, r3 - 80006b8: 46bd mov sp, r7 - 80006ba: b004 add sp, #16 - 80006bc: bd80 pop {r7, pc} - 80006be: 46c0 nop ; (mov r8, r8) - 80006c0: e000e010 .word 0xe000e010 - 80006c4: 8f0d17ff .word 0x8f0d17ff - 80006c8: 40022000 .word 0x40022000 - 80006cc: 89abcdef .word 0x89abcdef - 80006d0: 02030405 .word 0x02030405 + 80005a6: 0018 movs r0, r3 + 80005a8: 46bd mov sp, r7 + 80005aa: b004 add sp, #16 + 80005ac: bd80 pop {r7, pc} + 80005ae: 46c0 nop ; (mov r8, r8) + 80005b0: e000e010 .word 0xe000e010 + 80005b4: 8f0d17ff .word 0x8f0d17ff + 80005b8: 40022000 .word 0x40022000 + 80005bc: 89abcdef .word 0x89abcdef + 80005c0: 02030405 .word 0x02030405 -080006d4 : - -static int8_t eeprom_program_byte(uint32_t addr, uint8_t ee_data) -{ - 80006d4: b580 push {r7, lr} - 80006d6: b082 sub sp, #8 - 80006d8: af00 add r7, sp, #0 - 80006da: 6078 str r0, [r7, #4] - 80006dc: 000a movs r2, r1 - 80006de: 1cfb adds r3, r7, #3 - 80006e0: 701a strb r2, [r3, #0] - if ((EEPROM_ADDR_START <= addr) && (addr <= EEPROM_ADDR_END - 1)) - 80006e2: 687b ldr r3, [r7, #4] - 80006e4: 4a0d ldr r2, [pc, #52] ; (800071c ) - 80006e6: 4293 cmp r3, r2 - 80006e8: d912 bls.n 8000710 - 80006ea: 687b ldr r3, [r7, #4] - 80006ec: 4a0c ldr r2, [pc, #48] ; (8000720 ) - 80006ee: 4293 cmp r3, r2 - 80006f0: d80e bhi.n 8000710 - { - *(uint8_t *)(addr) = ee_data; /* write data to EEPROM */ - 80006f2: 687b ldr r3, [r7, #4] - 80006f4: 1cfa adds r2, r7, #3 - 80006f6: 7812 ldrb r2, [r2, #0] - 80006f8: 701a strb r2, [r3, #0] - if (*(uint8_t *)(addr) != ee_data) - 80006fa: 687b ldr r3, [r7, #4] - 80006fc: 781b ldrb r3, [r3, #0] - 80006fe: 1cfa adds r2, r7, #3 - 8000700: 7812 ldrb r2, [r2, #0] - 8000702: 429a cmp r2, r3 - 8000704: d002 beq.n 800070c - { - return EEPROM_WRITE_ERROR; - 8000706: 2304 movs r3, #4 - 8000708: 425b negs r3, r3 - 800070a: e003 b.n 8000714 - } - return EEPROM_OK; - 800070c: 2300 movs r3, #0 - 800070e: e001 b.n 8000714 - } else +080005c4 : { return EEPROM_ADDR_ERROR; - 8000710: 2305 movs r3, #5 - 8000712: 425b negs r3, r3 } } - 8000714: 0018 movs r0, r3 - 8000716: 46bd mov sp, r7 - 8000718: b002 add sp, #8 - 800071a: bd80 pop {r7, pc} - 800071c: 0807ffff .word 0x0807ffff - 8000720: 080803fe .word 0x080803fe - -08000724 : static int8_t eeprom_program_halfword(uint32_t addr, uint16_t ee_data) { - 8000724: b580 push {r7, lr} - 8000726: b082 sub sp, #8 - 8000728: af00 add r7, sp, #0 - 800072a: 6078 str r0, [r7, #4] - 800072c: 000a movs r2, r1 - 800072e: 1cbb adds r3, r7, #2 - 8000730: 801a strh r2, [r3, #0] + 80005c4: b580 push {r7, lr} + 80005c6: b082 sub sp, #8 + 80005c8: af00 add r7, sp, #0 + 80005ca: 6078 str r0, [r7, #4] + 80005cc: 000a movs r2, r1 + 80005ce: 1cbb adds r3, r7, #2 + 80005d0: 801a strh r2, [r3, #0] if ((EEPROM_ADDR_START <= addr) && (addr <= EEPROM_ADDR_END - 2)) - 8000732: 687b ldr r3, [r7, #4] - 8000734: 4a0d ldr r2, [pc, #52] ; (800076c ) - 8000736: 4293 cmp r3, r2 - 8000738: d912 bls.n 8000760 - 800073a: 687b ldr r3, [r7, #4] - 800073c: 4a0c ldr r2, [pc, #48] ; (8000770 ) - 800073e: 4293 cmp r3, r2 - 8000740: d80e bhi.n 8000760 + 80005d2: 687b ldr r3, [r7, #4] + 80005d4: 4a0d ldr r2, [pc, #52] ; (800060c ) + 80005d6: 4293 cmp r3, r2 + 80005d8: d912 bls.n 8000600 + 80005da: 687b ldr r3, [r7, #4] + 80005dc: 4a0c ldr r2, [pc, #48] ; (8000610 ) + 80005de: 4293 cmp r3, r2 + 80005e0: d80e bhi.n 8000600 { *(uint16_t *)(addr) = ee_data; /* write data to EEPROM */ - 8000742: 687b ldr r3, [r7, #4] - 8000744: 1cba adds r2, r7, #2 - 8000746: 8812 ldrh r2, [r2, #0] - 8000748: 801a strh r2, [r3, #0] + 80005e2: 687b ldr r3, [r7, #4] + 80005e4: 1cba adds r2, r7, #2 + 80005e6: 8812 ldrh r2, [r2, #0] + 80005e8: 801a strh r2, [r3, #0] if (*(uint16_t *)(addr) != ee_data) - 800074a: 687b ldr r3, [r7, #4] - 800074c: 881b ldrh r3, [r3, #0] - 800074e: 1cba adds r2, r7, #2 - 8000750: 8812 ldrh r2, [r2, #0] - 8000752: 429a cmp r2, r3 - 8000754: d002 beq.n 800075c + 80005ea: 687b ldr r3, [r7, #4] + 80005ec: 881b ldrh r3, [r3, #0] + 80005ee: 1cba adds r2, r7, #2 + 80005f0: 8812 ldrh r2, [r2, #0] + 80005f2: 429a cmp r2, r3 + 80005f4: d002 beq.n 80005fc { return EEPROM_WRITE_ERROR; - 8000756: 2304 movs r3, #4 - 8000758: 425b negs r3, r3 - 800075a: e003 b.n 8000764 + 80005f6: 2304 movs r3, #4 + 80005f8: 425b negs r3, r3 + 80005fa: e003 b.n 8000604 } return EEPROM_OK; - 800075c: 2300 movs r3, #0 - 800075e: e001 b.n 8000764 + 80005fc: 2300 movs r3, #0 + 80005fe: e001 b.n 8000604 } else { return EEPROM_ADDR_ERROR; - 8000760: 2305 movs r3, #5 - 8000762: 425b negs r3, r3 + 8000600: 2305 movs r3, #5 + 8000602: 425b negs r3, r3 } } - 8000764: 0018 movs r0, r3 - 8000766: 46bd mov sp, r7 - 8000768: b002 add sp, #8 - 800076a: bd80 pop {r7, pc} - 800076c: 0807ffff .word 0x0807ffff - 8000770: 080803fd .word 0x080803fd + 8000604: 0018 movs r0, r3 + 8000606: 46bd mov sp, r7 + 8000608: b002 add sp, #8 + 800060a: bd80 pop {r7, pc} + 800060c: 0807ffff .word 0x0807ffff + 8000610: 080803fd .word 0x080803fd -08000774 : - -#include "crc8.h" - -/* Stolen from Sensirion SCD4x datasheet, section 3.11 */ -uint8_t crc8_calculate(const uint8_t *data, uint16_t count) -{ - 8000774: b580 push {r7, lr} - 8000776: b084 sub sp, #16 - 8000778: af00 add r7, sp, #0 - 800077a: 6078 str r0, [r7, #4] - 800077c: 000a movs r2, r1 - 800077e: 1cbb adds r3, r7, #2 - 8000780: 801a strh r2, [r3, #0] - uint16_t current_byte; - uint8_t crc = CRC8_INIT; - 8000782: 230d movs r3, #13 - 8000784: 18fb adds r3, r7, r3 - 8000786: 22ff movs r2, #255 ; 0xff - 8000788: 701a strb r2, [r3, #0] - uint8_t crc_bit; - /* calculates 8-Bit checksum with given polynomial */ - for (current_byte = 0; current_byte < count; ++current_byte) { - 800078a: 230e movs r3, #14 - 800078c: 18fb adds r3, r7, r3 - 800078e: 2200 movs r2, #0 - 8000790: 801a strh r2, [r3, #0] - 8000792: e037 b.n 8000804 - crc ^= (data[current_byte]); - 8000794: 230e movs r3, #14 - 8000796: 18fb adds r3, r7, r3 - 8000798: 881b ldrh r3, [r3, #0] - 800079a: 687a ldr r2, [r7, #4] - 800079c: 18d3 adds r3, r2, r3 - 800079e: 7819 ldrb r1, [r3, #0] - 80007a0: 220d movs r2, #13 - 80007a2: 18bb adds r3, r7, r2 - 80007a4: 18ba adds r2, r7, r2 - 80007a6: 7812 ldrb r2, [r2, #0] - 80007a8: 404a eors r2, r1 - 80007aa: 701a strb r2, [r3, #0] - for(crc_bit = 8; crc_bit > 0; --crc_bit) { - 80007ac: 230c movs r3, #12 - 80007ae: 18fb adds r3, r7, r3 - 80007b0: 2208 movs r2, #8 - 80007b2: 701a strb r2, [r3, #0] - 80007b4: e01b b.n 80007ee - if (crc & 0x80) { - 80007b6: 210d movs r1, #13 - 80007b8: 187b adds r3, r7, r1 - 80007ba: 781b ldrb r3, [r3, #0] - 80007bc: b25b sxtb r3, r3 - 80007be: 2b00 cmp r3, #0 - 80007c0: da09 bge.n 80007d6 - crc =(crc << 1) ^ CRC8_POLYNOMIAL; - 80007c2: 187b adds r3, r7, r1 - 80007c4: 781b ldrb r3, [r3, #0] - 80007c6: 005b lsls r3, r3, #1 - 80007c8: b25b sxtb r3, r3 - 80007ca: 2231 movs r2, #49 ; 0x31 - 80007cc: 4053 eors r3, r2 - 80007ce: b25a sxtb r2, r3 - 80007d0: 187b adds r3, r7, r1 - 80007d2: 701a strb r2, [r3, #0] - 80007d4: e005 b.n 80007e2 - } else { - crc = (crc << 1); - 80007d6: 230d movs r3, #13 - 80007d8: 18fa adds r2, r7, r3 - 80007da: 18fb adds r3, r7, r3 - 80007dc: 781b ldrb r3, [r3, #0] - 80007de: 18db adds r3, r3, r3 - 80007e0: 7013 strb r3, [r2, #0] - for(crc_bit = 8; crc_bit > 0; --crc_bit) { - 80007e2: 220c movs r2, #12 - 80007e4: 18bb adds r3, r7, r2 - 80007e6: 18ba adds r2, r7, r2 - 80007e8: 7812 ldrb r2, [r2, #0] - 80007ea: 3a01 subs r2, #1 - 80007ec: 701a strb r2, [r3, #0] - 80007ee: 230c movs r3, #12 - 80007f0: 18fb adds r3, r7, r3 - 80007f2: 781b ldrb r3, [r3, #0] - 80007f4: 2b00 cmp r3, #0 - 80007f6: d1de bne.n 80007b6 - for (current_byte = 0; current_byte < count; ++current_byte) { - 80007f8: 220e movs r2, #14 - 80007fa: 18bb adds r3, r7, r2 - 80007fc: 18ba adds r2, r7, r2 - 80007fe: 8812 ldrh r2, [r2, #0] - 8000800: 3201 adds r2, #1 - 8000802: 801a strh r2, [r3, #0] - 8000804: 230e movs r3, #14 - 8000806: 18fa adds r2, r7, r3 - 8000808: 1cbb adds r3, r7, #2 - 800080a: 8812 ldrh r2, [r2, #0] - 800080c: 881b ldrh r3, [r3, #0] - 800080e: 429a cmp r2, r3 - 8000810: d3c0 bcc.n 8000794 - } - } - } - return crc; - 8000812: 230d movs r3, #13 - 8000814: 18fb adds r3, r7, r3 - 8000816: 781b ldrb r3, [r3, #0] -} - 8000818: 0018 movs r0, r3 - 800081a: 46bd mov sp, r7 - 800081c: b004 add sp, #16 - 800081e: bd80 pop {r7, pc} - -08000820 : +08000614 : * @rmtoll ISR TXE LL_I2C_IsActiveFlag_TXE * @param I2Cx I2C Instance. * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TXE(I2C_TypeDef *I2Cx) { - 8000820: b580 push {r7, lr} - 8000822: b082 sub sp, #8 - 8000824: af00 add r7, sp, #0 - 8000826: 6078 str r0, [r7, #4] + 8000614: b580 push {r7, lr} + 8000616: b082 sub sp, #8 + 8000618: af00 add r7, sp, #0 + 800061a: 6078 str r0, [r7, #4] return ((READ_BIT(I2Cx->ISR, I2C_ISR_TXE) == (I2C_ISR_TXE)) ? 1UL : 0UL); - 8000828: 687b ldr r3, [r7, #4] - 800082a: 699b ldr r3, [r3, #24] - 800082c: 2201 movs r2, #1 - 800082e: 4013 ands r3, r2 - 8000830: 2b01 cmp r3, #1 - 8000832: d101 bne.n 8000838 - 8000834: 2301 movs r3, #1 - 8000836: e000 b.n 800083a - 8000838: 2300 movs r3, #0 + 800061c: 687b ldr r3, [r7, #4] + 800061e: 699b ldr r3, [r3, #24] + 8000620: 2201 movs r2, #1 + 8000622: 4013 ands r3, r2 + 8000624: 2b01 cmp r3, #1 + 8000626: d101 bne.n 800062c + 8000628: 2301 movs r3, #1 + 800062a: e000 b.n 800062e + 800062c: 2300 movs r3, #0 } - 800083a: 0018 movs r0, r3 - 800083c: 46bd mov sp, r7 - 800083e: b002 add sp, #8 - 8000840: bd80 pop {r7, pc} + 800062e: 0018 movs r0, r3 + 8000630: 46bd mov sp, r7 + 8000632: b002 add sp, #8 + 8000634: bd80 pop {r7, pc} -08000842 : +08000636 : * @rmtoll ISR RXNE LL_I2C_IsActiveFlag_RXNE * @param I2Cx I2C Instance. * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_RXNE(I2C_TypeDef *I2Cx) { - 8000842: b580 push {r7, lr} - 8000844: b082 sub sp, #8 - 8000846: af00 add r7, sp, #0 - 8000848: 6078 str r0, [r7, #4] + 8000636: b580 push {r7, lr} + 8000638: b082 sub sp, #8 + 800063a: af00 add r7, sp, #0 + 800063c: 6078 str r0, [r7, #4] return ((READ_BIT(I2Cx->ISR, I2C_ISR_RXNE) == (I2C_ISR_RXNE)) ? 1UL : 0UL); - 800084a: 687b ldr r3, [r7, #4] - 800084c: 699b ldr r3, [r3, #24] - 800084e: 2204 movs r2, #4 - 8000850: 4013 ands r3, r2 - 8000852: 2b04 cmp r3, #4 - 8000854: d101 bne.n 800085a - 8000856: 2301 movs r3, #1 - 8000858: e000 b.n 800085c - 800085a: 2300 movs r3, #0 + 800063e: 687b ldr r3, [r7, #4] + 8000640: 699b ldr r3, [r3, #24] + 8000642: 2204 movs r2, #4 + 8000644: 4013 ands r3, r2 + 8000646: 2b04 cmp r3, #4 + 8000648: d101 bne.n 800064e + 800064a: 2301 movs r3, #1 + 800064c: e000 b.n 8000650 + 800064e: 2300 movs r3, #0 } - 800085c: 0018 movs r0, r3 - 800085e: 46bd mov sp, r7 - 8000860: b002 add sp, #8 - 8000862: bd80 pop {r7, pc} + 8000650: 0018 movs r0, r3 + 8000652: 46bd mov sp, r7 + 8000654: b002 add sp, #8 + 8000656: bd80 pop {r7, pc} -08000864 : +08000658 : * @rmtoll ISR STOPF LL_I2C_IsActiveFlag_STOP * @param I2Cx I2C Instance. * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_STOP(I2C_TypeDef *I2Cx) { - 8000864: b580 push {r7, lr} - 8000866: b082 sub sp, #8 - 8000868: af00 add r7, sp, #0 - 800086a: 6078 str r0, [r7, #4] + 8000658: b580 push {r7, lr} + 800065a: b082 sub sp, #8 + 800065c: af00 add r7, sp, #0 + 800065e: 6078 str r0, [r7, #4] return ((READ_BIT(I2Cx->ISR, I2C_ISR_STOPF) == (I2C_ISR_STOPF)) ? 1UL : 0UL); - 800086c: 687b ldr r3, [r7, #4] - 800086e: 699b ldr r3, [r3, #24] - 8000870: 2220 movs r2, #32 - 8000872: 4013 ands r3, r2 - 8000874: 2b20 cmp r3, #32 - 8000876: d101 bne.n 800087c - 8000878: 2301 movs r3, #1 - 800087a: e000 b.n 800087e - 800087c: 2300 movs r3, #0 + 8000660: 687b ldr r3, [r7, #4] + 8000662: 699b ldr r3, [r3, #24] + 8000664: 2220 movs r2, #32 + 8000666: 4013 ands r3, r2 + 8000668: 2b20 cmp r3, #32 + 800066a: d101 bne.n 8000670 + 800066c: 2301 movs r3, #1 + 800066e: e000 b.n 8000672 + 8000670: 2300 movs r3, #0 } - 800087e: 0018 movs r0, r3 - 8000880: 46bd mov sp, r7 - 8000882: b002 add sp, #8 - 8000884: bd80 pop {r7, pc} + 8000672: 0018 movs r0, r3 + 8000674: 46bd mov sp, r7 + 8000676: b002 add sp, #8 + 8000678: bd80 pop {r7, pc} -08000886 : +0800067a : * @rmtoll ICR STOPCF LL_I2C_ClearFlag_STOP * @param I2Cx I2C Instance. * @retval None */ __STATIC_INLINE void LL_I2C_ClearFlag_STOP(I2C_TypeDef *I2Cx) { - 8000886: b580 push {r7, lr} - 8000888: b082 sub sp, #8 - 800088a: af00 add r7, sp, #0 - 800088c: 6078 str r0, [r7, #4] + 800067a: b580 push {r7, lr} + 800067c: b082 sub sp, #8 + 800067e: af00 add r7, sp, #0 + 8000680: 6078 str r0, [r7, #4] SET_BIT(I2Cx->ICR, I2C_ICR_STOPCF); - 800088e: 687b ldr r3, [r7, #4] - 8000890: 69db ldr r3, [r3, #28] - 8000892: 2220 movs r2, #32 - 8000894: 431a orrs r2, r3 - 8000896: 687b ldr r3, [r7, #4] - 8000898: 61da str r2, [r3, #28] + 8000682: 687b ldr r3, [r7, #4] + 8000684: 69db ldr r3, [r3, #28] + 8000686: 2220 movs r2, #32 + 8000688: 431a orrs r2, r3 + 800068a: 687b ldr r3, [r7, #4] + 800068c: 61da str r2, [r3, #28] } - 800089a: 46c0 nop ; (mov r8, r8) - 800089c: 46bd mov sp, r7 - 800089e: b002 add sp, #8 - 80008a0: bd80 pop {r7, pc} + 800068e: 46c0 nop ; (mov r8, r8) + 8000690: 46bd mov sp, r7 + 8000692: b002 add sp, #8 + 8000694: bd80 pop {r7, pc} -080008a2 : +08000696 : * @rmtoll ISR TXE LL_I2C_ClearFlag_TXE * @param I2Cx I2C Instance. * @retval None */ __STATIC_INLINE void LL_I2C_ClearFlag_TXE(I2C_TypeDef *I2Cx) { - 80008a2: b580 push {r7, lr} - 80008a4: b082 sub sp, #8 - 80008a6: af00 add r7, sp, #0 - 80008a8: 6078 str r0, [r7, #4] + 8000696: b580 push {r7, lr} + 8000698: b082 sub sp, #8 + 800069a: af00 add r7, sp, #0 + 800069c: 6078 str r0, [r7, #4] WRITE_REG(I2Cx->ISR, I2C_ISR_TXE); - 80008aa: 687b ldr r3, [r7, #4] - 80008ac: 2201 movs r2, #1 - 80008ae: 619a str r2, [r3, #24] + 800069e: 687b ldr r3, [r7, #4] + 80006a0: 2201 movs r2, #1 + 80006a2: 619a str r2, [r3, #24] } - 80008b0: 46c0 nop ; (mov r8, r8) - 80008b2: 46bd mov sp, r7 - 80008b4: b002 add sp, #8 - 80008b6: bd80 pop {r7, pc} + 80006a4: 46c0 nop ; (mov r8, r8) + 80006a6: 46bd mov sp, r7 + 80006a8: b002 add sp, #8 + 80006aa: bd80 pop {r7, pc} -080008b8 : +080006ac : * @arg @ref LL_I2C_GENERATE_RESTART_10BIT_WRITE * @retval None */ __STATIC_INLINE void LL_I2C_HandleTransfer(I2C_TypeDef *I2Cx, uint32_t SlaveAddr, uint32_t SlaveAddrSize, uint32_t TransferSize, uint32_t EndMode, uint32_t Request) { - 80008b8: b580 push {r7, lr} - 80008ba: b084 sub sp, #16 - 80008bc: af00 add r7, sp, #0 - 80008be: 60f8 str r0, [r7, #12] - 80008c0: 60b9 str r1, [r7, #8] - 80008c2: 607a str r2, [r7, #4] - 80008c4: 603b str r3, [r7, #0] + 80006ac: b580 push {r7, lr} + 80006ae: b084 sub sp, #16 + 80006b0: af00 add r7, sp, #0 + 80006b2: 60f8 str r0, [r7, #12] + 80006b4: 60b9 str r1, [r7, #8] + 80006b6: 607a str r2, [r7, #4] + 80006b8: 603b str r3, [r7, #0] MODIFY_REG(I2Cx->CR2, I2C_CR2_SADD | I2C_CR2_ADD10 | - 80008c6: 68fb ldr r3, [r7, #12] - 80008c8: 685b ldr r3, [r3, #4] - 80008ca: 69fa ldr r2, [r7, #28] - 80008cc: 0d51 lsrs r1, r2, #21 - 80008ce: 2280 movs r2, #128 ; 0x80 - 80008d0: 00d2 lsls r2, r2, #3 - 80008d2: 400a ands r2, r1 - 80008d4: 490a ldr r1, [pc, #40] ; (8000900 ) - 80008d6: 430a orrs r2, r1 - 80008d8: 43d2 mvns r2, r2 - 80008da: 401a ands r2, r3 - 80008dc: 68b9 ldr r1, [r7, #8] - 80008de: 687b ldr r3, [r7, #4] - 80008e0: 4319 orrs r1, r3 - 80008e2: 683b ldr r3, [r7, #0] - 80008e4: 041b lsls r3, r3, #16 - 80008e6: 4319 orrs r1, r3 - 80008e8: 69bb ldr r3, [r7, #24] - 80008ea: 4319 orrs r1, r3 - 80008ec: 69fb ldr r3, [r7, #28] - 80008ee: 430b orrs r3, r1 - 80008f0: 431a orrs r2, r3 - 80008f2: 68fb ldr r3, [r7, #12] - 80008f4: 605a str r2, [r3, #4] + 80006ba: 68fb ldr r3, [r7, #12] + 80006bc: 685b ldr r3, [r3, #4] + 80006be: 69fa ldr r2, [r7, #28] + 80006c0: 0d51 lsrs r1, r2, #21 + 80006c2: 2280 movs r2, #128 ; 0x80 + 80006c4: 00d2 lsls r2, r2, #3 + 80006c6: 400a ands r2, r1 + 80006c8: 490a ldr r1, [pc, #40] ; (80006f4 ) + 80006ca: 430a orrs r2, r1 + 80006cc: 43d2 mvns r2, r2 + 80006ce: 401a ands r2, r3 + 80006d0: 68b9 ldr r1, [r7, #8] + 80006d2: 687b ldr r3, [r7, #4] + 80006d4: 4319 orrs r1, r3 + 80006d6: 683b ldr r3, [r7, #0] + 80006d8: 041b lsls r3, r3, #16 + 80006da: 4319 orrs r1, r3 + 80006dc: 69bb ldr r3, [r7, #24] + 80006de: 4319 orrs r1, r3 + 80006e0: 69fb ldr r3, [r7, #28] + 80006e2: 430b orrs r3, r1 + 80006e4: 431a orrs r2, r3 + 80006e6: 68fb ldr r3, [r7, #12] + 80006e8: 605a str r2, [r3, #4] (I2C_CR2_RD_WRN & (uint32_t)(Request >> (31U - I2C_CR2_RD_WRN_Pos))) | I2C_CR2_START | I2C_CR2_STOP | I2C_CR2_RELOAD | I2C_CR2_NBYTES | I2C_CR2_AUTOEND | I2C_CR2_HEAD10R, SlaveAddr | SlaveAddrSize | (TransferSize << I2C_CR2_NBYTES_Pos) | EndMode | Request); } - 80008f6: 46c0 nop ; (mov r8, r8) - 80008f8: 46bd mov sp, r7 - 80008fa: b004 add sp, #16 - 80008fc: bd80 pop {r7, pc} - 80008fe: 46c0 nop ; (mov r8, r8) - 8000900: 03ff7bff .word 0x03ff7bff + 80006ea: 46c0 nop ; (mov r8, r8) + 80006ec: 46bd mov sp, r7 + 80006ee: b004 add sp, #16 + 80006f0: bd80 pop {r7, pc} + 80006f2: 46c0 nop ; (mov r8, r8) + 80006f4: 03ff7bff .word 0x03ff7bff -08000904 : +080006f8 : * @rmtoll RXDR RXDATA LL_I2C_ReceiveData8 * @param I2Cx I2C Instance. * @retval Value between Min_Data=0x00 and Max_Data=0xFF */ __STATIC_INLINE uint8_t LL_I2C_ReceiveData8(I2C_TypeDef *I2Cx) { - 8000904: b580 push {r7, lr} - 8000906: b082 sub sp, #8 - 8000908: af00 add r7, sp, #0 - 800090a: 6078 str r0, [r7, #4] + 80006f8: b580 push {r7, lr} + 80006fa: b082 sub sp, #8 + 80006fc: af00 add r7, sp, #0 + 80006fe: 6078 str r0, [r7, #4] return (uint8_t)(READ_BIT(I2Cx->RXDR, I2C_RXDR_RXDATA)); - 800090c: 687b ldr r3, [r7, #4] - 800090e: 6a5b ldr r3, [r3, #36] ; 0x24 - 8000910: b2db uxtb r3, r3 + 8000700: 687b ldr r3, [r7, #4] + 8000702: 6a5b ldr r3, [r3, #36] ; 0x24 + 8000704: b2db uxtb r3, r3 } - 8000912: 0018 movs r0, r3 - 8000914: 46bd mov sp, r7 - 8000916: b002 add sp, #8 - 8000918: bd80 pop {r7, pc} + 8000706: 0018 movs r0, r3 + 8000708: 46bd mov sp, r7 + 800070a: b002 add sp, #8 + 800070c: bd80 pop {r7, pc} -0800091a : +0800070e : * @param I2Cx I2C Instance. * @param Data Value between Min_Data=0x00 and Max_Data=0xFF * @retval None */ __STATIC_INLINE void LL_I2C_TransmitData8(I2C_TypeDef *I2Cx, uint8_t Data) { - 800091a: b580 push {r7, lr} - 800091c: b082 sub sp, #8 - 800091e: af00 add r7, sp, #0 - 8000920: 6078 str r0, [r7, #4] - 8000922: 000a movs r2, r1 - 8000924: 1cfb adds r3, r7, #3 - 8000926: 701a strb r2, [r3, #0] + 800070e: b580 push {r7, lr} + 8000710: b082 sub sp, #8 + 8000712: af00 add r7, sp, #0 + 8000714: 6078 str r0, [r7, #4] + 8000716: 000a movs r2, r1 + 8000718: 1cfb adds r3, r7, #3 + 800071a: 701a strb r2, [r3, #0] WRITE_REG(I2Cx->TXDR, Data); - 8000928: 1cfb adds r3, r7, #3 - 800092a: 781a ldrb r2, [r3, #0] - 800092c: 687b ldr r3, [r7, #4] - 800092e: 629a str r2, [r3, #40] ; 0x28 + 800071c: 1cfb adds r3, r7, #3 + 800071e: 781a ldrb r2, [r3, #0] + 8000720: 687b ldr r3, [r7, #4] + 8000722: 629a str r2, [r3, #40] ; 0x28 } - 8000930: 46c0 nop ; (mov r8, r8) - 8000932: 46bd mov sp, r7 - 8000934: b002 add sp, #8 - 8000936: bd80 pop {r7, pc} + 8000724: 46c0 nop ; (mov r8, r8) + 8000726: 46bd mov sp, r7 + 8000728: b002 add sp, #8 + 800072a: bd80 pop {r7, pc} -08000938 : +0800072c : #include "stm32l0xx_ll_usart.h" static i2c_context_t *i2c_context; int8_t i2c_init(i2c_context_t *context) { - 8000938: b580 push {r7, lr} - 800093a: b082 sub sp, #8 - 800093c: af00 add r7, sp, #0 - 800093e: 6078 str r0, [r7, #4] + 800072c: b580 push {r7, lr} + 800072e: b082 sub sp, #8 + 8000730: af00 add r7, sp, #0 + 8000732: 6078 str r0, [r7, #4] if (context == NULL) { - 8000940: 687b ldr r3, [r7, #4] - 8000942: 2b00 cmp r3, #0 - 8000944: d102 bne.n 800094c + 8000734: 687b ldr r3, [r7, #4] + 8000736: 2b00 cmp r3, #0 + 8000738: d102 bne.n 8000740 return I2C_ERROR; - 8000946: 2301 movs r3, #1 - 8000948: 425b negs r3, r3 - 800094a: e003 b.n 8000954 + 800073a: 2301 movs r3, #1 + 800073c: 425b negs r3, r3 + 800073e: e003 b.n 8000748 } i2c_context = context; - 800094c: 4b03 ldr r3, [pc, #12] ; (800095c ) - 800094e: 687a ldr r2, [r7, #4] - 8000950: 601a str r2, [r3, #0] + 8000740: 4b03 ldr r3, [pc, #12] ; (8000750 ) + 8000742: 687a ldr r2, [r7, #4] + 8000744: 601a str r2, [r3, #0] return I2C_OK; - 8000952: 2300 movs r3, #0 + 8000746: 2300 movs r3, #0 } - 8000954: 0018 movs r0, r3 - 8000956: 46bd mov sp, r7 - 8000958: b002 add sp, #8 - 800095a: bd80 pop {r7, pc} - 800095c: 20000024 .word 0x20000024 + 8000748: 0018 movs r0, r3 + 800074a: 46bd mov sp, r7 + 800074c: b002 add sp, #8 + 800074e: bd80 pop {r7, pc} + 8000750: 20000024 .word 0x20000024 -08000960 : +08000754 : int8_t i2c_transmit(uint8_t address, uint8_t *buffer, int len) { - 8000960: b580 push {r7, lr} - 8000962: b088 sub sp, #32 - 8000964: af02 add r7, sp, #8 - 8000966: 60b9 str r1, [r7, #8] - 8000968: 607a str r2, [r7, #4] - 800096a: 210f movs r1, #15 - 800096c: 187b adds r3, r7, r1 - 800096e: 1c02 adds r2, r0, #0 - 8000970: 701a strb r2, [r3, #0] + 8000754: b580 push {r7, lr} + 8000756: b088 sub sp, #32 + 8000758: af02 add r7, sp, #8 + 800075a: 60b9 str r1, [r7, #8] + 800075c: 607a str r2, [r7, #4] + 800075e: 210f movs r1, #15 + 8000760: 187b adds r3, r7, r1 + 8000762: 1c02 adds r2, r0, #0 + 8000764: 701a strb r2, [r3, #0] LL_I2C_HandleTransfer(i2c_context->i2c, address, LL_I2C_ADDRSLAVE_7BIT, len, - 8000972: 4b25 ldr r3, [pc, #148] ; (8000a08 ) - 8000974: 681b ldr r3, [r3, #0] - 8000976: 6818 ldr r0, [r3, #0] - 8000978: 187b adds r3, r7, r1 - 800097a: 7819 ldrb r1, [r3, #0] - 800097c: 687a ldr r2, [r7, #4] - 800097e: 4b23 ldr r3, [pc, #140] ; (8000a0c ) - 8000980: 9301 str r3, [sp, #4] - 8000982: 2380 movs r3, #128 ; 0x80 - 8000984: 049b lsls r3, r3, #18 - 8000986: 9300 str r3, [sp, #0] - 8000988: 0013 movs r3, r2 - 800098a: 2200 movs r2, #0 - 800098c: f7ff ff94 bl 80008b8 + 8000766: 4b25 ldr r3, [pc, #148] ; (80007fc ) + 8000768: 681b ldr r3, [r3, #0] + 800076a: 6818 ldr r0, [r3, #0] + 800076c: 187b adds r3, r7, r1 + 800076e: 7819 ldrb r1, [r3, #0] + 8000770: 687a ldr r2, [r7, #4] + 8000772: 4b23 ldr r3, [pc, #140] ; (8000800 ) + 8000774: 9301 str r3, [sp, #4] + 8000776: 2380 movs r3, #128 ; 0x80 + 8000778: 049b lsls r3, r3, #18 + 800077a: 9300 str r3, [sp, #0] + 800077c: 0013 movs r3, r2 + 800077e: 2200 movs r2, #0 + 8000780: f7ff ff94 bl 80006ac LL_I2C_MODE_AUTOEND, LL_I2C_GENERATE_START_WRITE); int i = 0; - 8000990: 2300 movs r3, #0 - 8000992: 617b str r3, [r7, #20] + 8000784: 2300 movs r3, #0 + 8000786: 617b str r3, [r7, #20] /* Autoend mode will raise STOP flag if NACK is detected * (or if desired number of bytes is transmitted) */ while (!LL_I2C_IsActiveFlag_STOP(i2c_context->i2c)) { - 8000994: e018 b.n 80009c8 + 8000788: e018 b.n 80007bc if (LL_I2C_IsActiveFlag_TXE(i2c_context->i2c)) { - 8000996: 4b1c ldr r3, [pc, #112] ; (8000a08 ) - 8000998: 681b ldr r3, [r3, #0] - 800099a: 681b ldr r3, [r3, #0] - 800099c: 0018 movs r0, r3 - 800099e: f7ff ff3f bl 8000820 - 80009a2: 1e03 subs r3, r0, #0 - 80009a4: d010 beq.n 80009c8 + 800078a: 4b1c ldr r3, [pc, #112] ; (80007fc ) + 800078c: 681b ldr r3, [r3, #0] + 800078e: 681b ldr r3, [r3, #0] + 8000790: 0018 movs r0, r3 + 8000792: f7ff ff3f bl 8000614 + 8000796: 1e03 subs r3, r0, #0 + 8000798: d010 beq.n 80007bc if (i < len) { - 80009a6: 697a ldr r2, [r7, #20] - 80009a8: 687b ldr r3, [r7, #4] - 80009aa: 429a cmp r2, r3 - 80009ac: da0c bge.n 80009c8 + 800079a: 697a ldr r2, [r7, #20] + 800079c: 687b ldr r3, [r7, #4] + 800079e: 429a cmp r2, r3 + 80007a0: da0c bge.n 80007bc LL_I2C_TransmitData8(i2c_context->i2c, buffer[i++]); - 80009ae: 4b16 ldr r3, [pc, #88] ; (8000a08 ) - 80009b0: 681b ldr r3, [r3, #0] - 80009b2: 6818 ldr r0, [r3, #0] - 80009b4: 697b ldr r3, [r7, #20] - 80009b6: 1c5a adds r2, r3, #1 - 80009b8: 617a str r2, [r7, #20] - 80009ba: 001a movs r2, r3 - 80009bc: 68bb ldr r3, [r7, #8] - 80009be: 189b adds r3, r3, r2 - 80009c0: 781b ldrb r3, [r3, #0] - 80009c2: 0019 movs r1, r3 - 80009c4: f7ff ffa9 bl 800091a + 80007a2: 4b16 ldr r3, [pc, #88] ; (80007fc ) + 80007a4: 681b ldr r3, [r3, #0] + 80007a6: 6818 ldr r0, [r3, #0] + 80007a8: 697b ldr r3, [r7, #20] + 80007aa: 1c5a adds r2, r3, #1 + 80007ac: 617a str r2, [r7, #20] + 80007ae: 001a movs r2, r3 + 80007b0: 68bb ldr r3, [r7, #8] + 80007b2: 189b adds r3, r3, r2 + 80007b4: 781b ldrb r3, [r3, #0] + 80007b6: 0019 movs r1, r3 + 80007b8: f7ff ffa9 bl 800070e while (!LL_I2C_IsActiveFlag_STOP(i2c_context->i2c)) { - 80009c8: 4b0f ldr r3, [pc, #60] ; (8000a08 ) - 80009ca: 681b ldr r3, [r3, #0] - 80009cc: 681b ldr r3, [r3, #0] - 80009ce: 0018 movs r0, r3 - 80009d0: f7ff ff48 bl 8000864 - 80009d4: 1e03 subs r3, r0, #0 - 80009d6: d0de beq.n 8000996 + 80007bc: 4b0f ldr r3, [pc, #60] ; (80007fc ) + 80007be: 681b ldr r3, [r3, #0] + 80007c0: 681b ldr r3, [r3, #0] + 80007c2: 0018 movs r0, r3 + 80007c4: f7ff ff48 bl 8000658 + 80007c8: 1e03 subs r3, r0, #0 + 80007ca: d0de beq.n 800078a } } } LL_I2C_ClearFlag_STOP(i2c_context->i2c); - 80009d8: 4b0b ldr r3, [pc, #44] ; (8000a08