From 07cbb4f8fa8d97f952ec0597f10e8ca5da5903b5 Mon Sep 17 00:00:00 2001 From: Kerogit Date: Tue, 25 Nov 2025 12:18:56 +0100 Subject: [PATCH 1/2] boards/avr/avrdx/breadxavr: silence unused variable warning This patch silences a warning caused by unconditionally declared variable which is only used with specific configuration. Also, if the initialization fails, panic instead of returning. (This should not happen since the code runs in initialization phase but silently returning is not the correct action.) Signed-off-by: Kerogit --- boards/avr/avrdx/breadxavr/src/avrdx_init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/boards/avr/avrdx/breadxavr/src/avrdx_init.c b/boards/avr/avrdx/breadxavr/src/avrdx_init.c index 6e09599e38f5c..60dab014be1f9 100644 --- a/boards/avr/avrdx/breadxavr/src/avrdx_init.c +++ b/boards/avr/avrdx/breadxavr/src/avrdx_init.c @@ -32,6 +32,7 @@ # include #endif +#include #include #include "avrdx_gpio.h" @@ -77,13 +78,15 @@ #ifdef CONFIG_BOARD_EARLY_INITIALIZE void board_early_initialize(void) { +# ifdef CONFIG_BREADXAVR_BUTTONS_DRIVER int ret = OK; +# endif # ifdef CONFIG_BREADXAVR_BUTTONS_DRIVER ret = btn_lower_initialize("/dev/buttons"); if (ret != OK) { - return; + PANIC(); } # endif } From d3813e803ed3b059ff504c0b748334d6d8001fe8 Mon Sep 17 00:00:00 2001 From: Kerogit Date: Tue, 25 Nov 2025 12:21:25 +0100 Subject: [PATCH 2/2] boards/avr/avrdx/breadxavr: add TC74Ax thermal sensor to the board This patch adds the option to connect TC74Ax thermal sensor to AVR Dx chip connected to a breadboard for development purposes. If enabled - which can only be done with I2C support and the driver enabled - it registers sensor's driver for use. Signed-off-by: Kerogit --- .../avr/avrdx/boards/breadxavr/index.rst | 18 +++++++ boards/avr/avrdx/breadxavr/Kconfig | 22 ++++++++ boards/avr/avrdx/breadxavr/src/avrdx_init.c | 52 +++++++++++++++++++ 3 files changed, 92 insertions(+) diff --git a/Documentation/platforms/avr/avrdx/boards/breadxavr/index.rst b/Documentation/platforms/avr/avrdx/boards/breadxavr/index.rst index 1265766b284a8..f6b525cae269d 100644 --- a/Documentation/platforms/avr/avrdx/boards/breadxavr/index.rst +++ b/Documentation/platforms/avr/avrdx/boards/breadxavr/index.rst @@ -63,6 +63,24 @@ expectation that requires pressed button to read as logical 1 and depressed button as logical 0 while allowing the board to operate without external components (internal pull-ups are used.) +I\ :sup:`2`\ C temperature sensor TC74Ax +---------------------------------------- + +The board has readymade configuration for TC74Ax temperature sensor +from Microchip. + +To enable it, it is needed to: + + - enable :menuselection:`Device Drivers --> I2C Driver Support` + - enable :menuselection:`System Type --> AVR DA/DB Peripheral Selections --> Enable TWI (I2C) driver for interface 0` + - enable :menuselection:`Device Drivers --> Sensor Device Support --> Microchip TC74Ax Digital Thermal Sensor` + - configure the driver for requested mode of operation with regards + to multimaster and power management + - enable :menuselection:`Board Selection --> Enable initializing I2C TC74Ax sensor` + - configure variant of the connected sensor + +The sensor is made available as ``/dev/tc74ax``. Further information regarding usage of the sensor is available in its driver's documentation: :doc:`/components/drivers/special/sensors/tc74ax` + Compile & Flash =============== diff --git a/boards/avr/avrdx/breadxavr/Kconfig b/boards/avr/avrdx/breadxavr/Kconfig index 02f04fa121e9e..a516571aec69b 100644 --- a/boards/avr/avrdx/breadxavr/Kconfig +++ b/boards/avr/avrdx/breadxavr/Kconfig @@ -13,4 +13,26 @@ config BREADXAVR_BUTTONS_DRIVER If set, button driver registered as /dev/buttons for PORT A and PORT C (pins 2 and 3 for both ports.) +config BREADXAVR_TC74AX_SENSOR + bool "Enable initializing I2C TC74Ax sensor" + depends on AVR_TWI0 && SENSORS_TC74AX + select BOARD_LATE_INITIALIZE + default n + ---help--- + If set, the board will register driver for Microchip TC74Ax + thermal sensor. + +if BREADXAVR_TC74AX_SENSOR + +config BREADXAVR_TC74AX_SENSOR_VARIANT + int "TC74Ax variant" + default 0 + range 0 7 + ---help--- + Select specific part used on your (bread)board. Number chosen + here corresponds to the "x" in the part name (and also to I2C + address of the sensor.) + +endif + endif diff --git a/boards/avr/avrdx/breadxavr/src/avrdx_init.c b/boards/avr/avrdx/breadxavr/src/avrdx_init.c index 60dab014be1f9..30886df954631 100644 --- a/boards/avr/avrdx/breadxavr/src/avrdx_init.c +++ b/boards/avr/avrdx/breadxavr/src/avrdx_init.c @@ -32,10 +32,15 @@ # include #endif +#ifdef CONFIG_BREADXAVR_TC74AX_SENSOR +# include +#endif + #include #include #include "avrdx_gpio.h" +#include "avrdx_twi.h" /**************************************************************************** * Pre-processor Definitions @@ -92,3 +97,50 @@ void board_early_initialize(void) } #endif /* CONFIG_BOARD_EARLY_INITIALIZE */ + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * Function called by the OS when BOARD_LATE_INITIALIZE is set. + * Called after up_initialize, OS has been initialized at this point + * and it is okay to initialize drivers. Running in special kernel + * thread so waiting is allowed. Executed just before application code. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ +# ifdef CONFIG_BREADXAVR_TC74AX_SENSOR + FAR struct i2c_master_s *i2c; +# endif + int ret = OK; + +# ifdef CONFIG_BREADXAVR_TC74AX_SENSOR + +# if (CONFIG_BREADXAVR_TC74AX_SENSOR_VARIANT < 0) || \ + (CONFIG_BREADXAVR_TC74AX_SENSOR_VARIANT > 7) +# error Incorrect setting of variant, Kconfig should not allow this +# endif + + i2c = avrdx_initialize_twi(0); + if (i2c) + { + ret = tc74ax_register("/dev/tc74ax", + i2c, + 72 + CONFIG_BREADXAVR_TC74AX_SENSOR_VARIANT); + if (ret != OK) + { + PANIC(); + } + } + else + { + PANIC(); + } + +# endif /* ifdef CONFIG_BREADXAVR_TC74AX_SENSOR */ +} + +#endif /* CONFIG_BOARD_LATE_INITIALIZE */