Upgrade to Zephyr v3.2
This commit is contained in:
@@ -7,6 +7,7 @@ CONFIG_CPLUSPLUS=y
|
||||
CONFIG_LIB_CPLUSPLUS=y
|
||||
|
||||
CONFIG_NEWLIB_LIBC=y
|
||||
CONFIG_NEWLIB_LIBC_NANO=y
|
||||
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
|
||||
|
||||
CONFIG_WATCHDOG=y
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include "bat_charger.h"
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <logging/log.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(bat_charger, CONFIG_BAT_LOG_LEVEL);
|
||||
|
||||
#include <functional>
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* @brief Defines for conditional compiling based on existing board features
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#define BOARD_HAS_DCDC DT_HAS_COMPAT_STATUS_OKAY(half_bridge)
|
||||
#define BOARD_HAS_PWM_PORT DT_NODE_EXISTS(DT_CHILD(DT_PATH(outputs), pwm_switch))
|
||||
|
||||
+2
-2
@@ -6,9 +6,9 @@
|
||||
|
||||
#include "daq.h"
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <logging/log.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(daq, CONFIG_DAQ_LOG_LEVEL);
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <drivers/gpio.h>
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <stm32_ll_adc.h>
|
||||
#include <stm32_ll_bus.h>
|
||||
@@ -215,14 +215,15 @@ static void adc_init(ADC_TypeDef *adc)
|
||||
LL_ADC_Enable(adc);
|
||||
}
|
||||
|
||||
#define V_HIGH_ENABLE_GPIO DT_CHILD(DT_PATH(adc_inputs), v_high)
|
||||
#define V_HIGH_ENABLE_NODE DT_CHILD(DT_PATH(adc_inputs), v_high)
|
||||
|
||||
static void adc_setup()
|
||||
{
|
||||
#if DT_NODE_EXISTS(DT_PROP(V_HIGH_ENABLE_GPIO, enable_gpios))
|
||||
const struct device *dev = device_get_binding(DT_GPIO_LABEL(V_HIGH_ENABLE_GPIO, enable_gpios));
|
||||
gpio_pin_configure(dev, DT_GPIO_PIN(V_HIGH_ENABLE_GPIO, enable_gpios),
|
||||
DT_GPIO_FLAGS(V_HIGH_ENABLE_GPIO, enable_gpios) | GPIO_OUTPUT_ACTIVE);
|
||||
#if DT_NODE_EXISTS(DT_PROP(V_HIGH_ENABLE_NODE, enable_gpios))
|
||||
const struct gpio_dt_spec v_high_enable = GPIO_DT_SPEC_GET(V_HIGH_ENABLE_NODE, enable_gpios);
|
||||
if (device_is_ready(v_high_enable.port)) {
|
||||
gpio_pin_configure_dt(&v_high_enable, GPIO_OUTPUT_ACTIVE);
|
||||
}
|
||||
#endif
|
||||
|
||||
adc_init(ADC1);
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
#include "data_objects.h"
|
||||
|
||||
#include <soc.h>
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <drivers/hwinfo.h>
|
||||
#include <sys/crc.h>
|
||||
#include <zephyr/drivers/hwinfo.h>
|
||||
#include <zephyr/sys/crc.h>
|
||||
|
||||
#ifdef CONFIG_SOC_FAMILY_STM32
|
||||
#include <stm32_ll_utils.h>
|
||||
|
||||
+24
-13
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "data_storage.h"
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include "data_objects.h"
|
||||
#include "helper.h"
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#ifdef CONFIG_SOC_FAMILY_STM32
|
||||
|
||||
#include <device.h>
|
||||
#include <stm32_ll_bus.h>
|
||||
#include <zephyr/device.h>
|
||||
|
||||
LOG_MODULE_REGISTER(nvs, CONFIG_DATA_STORAGE_LOG_LEVEL);
|
||||
|
||||
@@ -57,7 +57,7 @@ uint32_t _calc_crc(const uint8_t *buf, size_t len)
|
||||
|
||||
#ifdef CONFIG_EEPROM
|
||||
|
||||
#include <drivers/eeprom.h>
|
||||
#include <zephyr/drivers/eeprom.h>
|
||||
|
||||
/*
|
||||
* EEPROM header bytes:
|
||||
@@ -69,11 +69,16 @@ uint32_t _calc_crc(const uint8_t *buf, size_t len)
|
||||
*/
|
||||
#define EEPROM_HEADER_SIZE 8
|
||||
|
||||
static const struct device *eeprom_dev = DEVICE_DT_GET(DT_NODELABEL(eeprom));
|
||||
|
||||
void data_storage_read()
|
||||
{
|
||||
int err;
|
||||
|
||||
const struct device *eeprom_dev = device_get_binding("EEPROM_0");
|
||||
if (!device_is_ready(eeprom_dev)) {
|
||||
LOG_ERR("EEPROM device not ready");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t buf_header[EEPROM_HEADER_SIZE] = {};
|
||||
err = eeprom_read(eeprom_dev, 0, buf_header, EEPROM_HEADER_SIZE);
|
||||
@@ -116,7 +121,10 @@ void data_storage_write()
|
||||
{
|
||||
int err;
|
||||
|
||||
const struct device *eeprom_dev = device_get_binding("EEPROM_0");
|
||||
if (!device_is_ready(eeprom_dev)) {
|
||||
LOG_ERR("EEPROM device not ready");
|
||||
return;
|
||||
}
|
||||
|
||||
k_mutex_lock(&data_buf_lock, K_FOREVER);
|
||||
|
||||
@@ -150,9 +158,9 @@ void data_storage_write()
|
||||
|
||||
#elif defined(CONFIG_NVS)
|
||||
|
||||
#include <drivers/flash.h>
|
||||
#include <fs/nvs.h>
|
||||
#include <storage/flash_map.h>
|
||||
#include <zephyr/drivers/flash.h>
|
||||
#include <zephyr/fs/nvs.h>
|
||||
#include <zephyr/storage/flash_map.h>
|
||||
|
||||
/*
|
||||
* NVS header bytes:
|
||||
@@ -162,7 +170,7 @@ void data_storage_write()
|
||||
*/
|
||||
#define NVS_HEADER_SIZE 2
|
||||
|
||||
#define STORAGE_NODE_LABEL storage
|
||||
#define NVS_PARTITION storage_partition
|
||||
|
||||
#define THINGSET_DATA_ID 1
|
||||
|
||||
@@ -174,19 +182,19 @@ static int data_storage_init()
|
||||
int err;
|
||||
struct flash_pages_info page_info;
|
||||
|
||||
fs.flash_device = FLASH_AREA_DEVICE(STORAGE_NODE_LABEL);
|
||||
fs.flash_device = FIXED_PARTITION_DEVICE(NVS_PARTITION);
|
||||
if (!device_is_ready(fs.flash_device)) {
|
||||
LOG_ERR("Flash device not ready");
|
||||
return -ENODEV;
|
||||
}
|
||||
fs.offset = FLASH_AREA_OFFSET(STORAGE_NODE_LABEL);
|
||||
fs.offset = FIXED_PARTITION_OFFSET(NVS_PARTITION);
|
||||
err = flash_get_page_info_by_offs(fs.flash_device, fs.offset, &page_info);
|
||||
if (err) {
|
||||
LOG_ERR("Unable to get flash page info");
|
||||
return err;
|
||||
}
|
||||
fs.sector_size = page_info.size;
|
||||
fs.sector_count = FLASH_AREA_SIZE(STORAGE_NODE_LABEL) / page_info.size;
|
||||
fs.sector_count = FIXED_PARTITION_SIZE(NVS_PARTITION) / page_info.size;
|
||||
|
||||
err = nvs_mount(&fs);
|
||||
if (err) {
|
||||
@@ -251,7 +259,10 @@ void data_storage_write()
|
||||
else {
|
||||
int ret = nvs_write(&fs, THINGSET_DATA_ID, &buf, len + NVS_HEADER_SIZE);
|
||||
if (ret == len + NVS_HEADER_SIZE) {
|
||||
LOG_INF("NVS data successfully stored");
|
||||
LOG_DBG("NVS data successfully stored");
|
||||
}
|
||||
else if (ret == 0) {
|
||||
LOG_DBG("NVS data unchanged");
|
||||
}
|
||||
else {
|
||||
LOG_ERR("NVS write error %d", ret);
|
||||
|
||||
+3
-3
@@ -6,10 +6,10 @@
|
||||
|
||||
#include "dcdc.h"
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <device.h>
|
||||
#include <drivers/gpio.h>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
|
||||
#include <math.h> // for fabs function
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "device_status.h"
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <math.h> // for fabs function
|
||||
#include <stdio.h>
|
||||
|
||||
+10
-14
@@ -6,17 +6,17 @@
|
||||
|
||||
#if CONFIG_THINGSET_CAN
|
||||
|
||||
#include <device.h>
|
||||
#include <drivers/can.h>
|
||||
#include <drivers/gpio.h>
|
||||
#include <task_wdt/task_wdt.h>
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/can.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/task_wdt/task_wdt.h>
|
||||
|
||||
#ifdef CONFIG_ISOTP
|
||||
#include <canbus/isotp.h>
|
||||
#include <zephyr/canbus/isotp.h>
|
||||
#endif
|
||||
|
||||
#include <logging/log.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(ext_can, CONFIG_CAN_LOG_LEVEL);
|
||||
|
||||
#include "bat_charger.h"
|
||||
@@ -144,7 +144,7 @@ K_THREAD_DEFINE(can_isotp, RX_THREAD_STACK_SIZE, can_isotp_thread, NULL, NULL, N
|
||||
|
||||
CAN_MSGQ_DEFINE(sub_msgq, 10);
|
||||
|
||||
const struct zcan_filter ctrl_filter = {
|
||||
const struct can_filter ctrl_filter = {
|
||||
.id = TS_CAN_BASE_CONTROL,
|
||||
.rtr = CAN_DATAFRAME,
|
||||
.id_type = CAN_EXTENDED_IDENTIFIER,
|
||||
@@ -159,7 +159,7 @@ void can_pub_isr(const struct device *dev, int error, void *user_data)
|
||||
|
||||
void can_pub_send(uint32_t can_id, uint8_t can_data[8], uint8_t data_len)
|
||||
{
|
||||
struct zcan_frame frame = { 0 };
|
||||
struct can_frame frame = { 0 };
|
||||
frame.id_type = CAN_EXTENDED_IDENTIFIER;
|
||||
frame.rtr = CAN_DATAFRAME;
|
||||
frame.id = can_id;
|
||||
@@ -180,11 +180,7 @@ void can_pubsub_thread()
|
||||
|
||||
unsigned int can_id;
|
||||
uint8_t can_data[8];
|
||||
struct zcan_frame rx_frame;
|
||||
|
||||
const struct device *can_en_dev = device_get_binding(DT_GPIO_LABEL(CAN_EN_GPIO, gpios));
|
||||
gpio_pin_configure(can_en_dev, DT_GPIO_PIN(CAN_EN_GPIO, gpios),
|
||||
DT_GPIO_FLAGS(CAN_EN_GPIO, gpios) | GPIO_OUTPUT_ACTIVE);
|
||||
struct can_frame rx_frame;
|
||||
|
||||
if (!device_is_ready(can_dev)) {
|
||||
return;
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <device.h>
|
||||
#include <drivers/gpio.h>
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include "oled_ssd1306.h"
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <drivers/uart.h>
|
||||
#include <sys/printk.h>
|
||||
#include <task_wdt/task_wdt.h>
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/drivers/uart.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
#include <zephyr/task_wdt/task_wdt.h>
|
||||
|
||||
#include "data_objects.h"
|
||||
#include "hardware.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "half_bridge.h"
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#include "mcu.h"
|
||||
|
||||
#ifdef CONFIG_SOC_FAMILY_STM32
|
||||
#include <drivers/pinctrl.h>
|
||||
#include <soc.h>
|
||||
#include <stm32_ll_bus.h>
|
||||
#include <zephyr/drivers/pinctrl.h>
|
||||
#endif
|
||||
|
||||
#if BOARD_HAS_DCDC
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
#ifndef UNIT_TEST
|
||||
|
||||
#if DT_NODE_EXISTS(DT_CHILD(DT_PATH(outputs), boot0))
|
||||
#define BOOT0_GPIO DT_CHILD(DT_PATH(outputs), boot0)
|
||||
#define BOOT0_NODE DT_CHILD(DT_PATH(outputs), boot0)
|
||||
#endif
|
||||
|
||||
#include <drivers/gpio.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/sys/reboot.h>
|
||||
|
||||
LOG_MODULE_REGISTER(hardware, CONFIG_HW_LOG_LEVEL);
|
||||
|
||||
@@ -28,12 +28,12 @@ void start_stm32_bootloader()
|
||||
{
|
||||
#if DT_NODE_EXISTS(DT_CHILD(DT_PATH(outputs), boot0))
|
||||
// pin is connected to BOOT0 via resistor and capacitor
|
||||
const struct device *dev = device_get_binding(DT_GPIO_LABEL(BOOT0_GPIO, gpios));
|
||||
gpio_pin_configure(dev, DT_GPIO_PIN(BOOT0_GPIO, gpios),
|
||||
DT_GPIO_FLAGS(BOOT0_GPIO, gpios) | GPIO_OUTPUT_ACTIVE);
|
||||
|
||||
k_sleep(K_MSEC(100)); // wait for capacitor at BOOT0 pin to charge up
|
||||
reset_device();
|
||||
const struct gpio_dt_spec boot0 = GPIO_DT_SPEC_GET(BOOT0_NODE, gpios);
|
||||
if (device_is_ready(boot0.port)) {
|
||||
gpio_pin_configure_dt(&boot0, GPIO_OUTPUT_ACTIVE);
|
||||
k_sleep(K_MSEC(100)); // wait for capacitor at BOOT0 pin to charge up
|
||||
reset_device();
|
||||
}
|
||||
#elif defined(CONFIG_SOC_SERIES_STM32G4X)
|
||||
if ((FLASH->CR & FLASH_CR_OPTLOCK) != 0U) {
|
||||
/* Authorizes the Option Byte register programming */
|
||||
|
||||
+2
-2
@@ -35,11 +35,11 @@
|
||||
|
||||
#else
|
||||
|
||||
#include <logging/log.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
#endif /* VSCODE_INTELLISENSE_HACK */
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
+19
-57
@@ -6,9 +6,11 @@
|
||||
|
||||
#include "leds.h"
|
||||
|
||||
#include <drivers/gpio.h>
|
||||
#include <task_wdt/task_wdt.h>
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/task_wdt/task_wdt.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "hardware.h"
|
||||
|
||||
@@ -65,57 +67,19 @@ static const int led_pin_states[NUM_LEDS][NUM_LED_PINS] = { DT_FOREACH_CHILD(DT_
|
||||
/*
|
||||
* GPIO pin numbers (for up to 5 LED pins)
|
||||
*/
|
||||
static const gpio_pin_t led_pins[] = {
|
||||
DT_PHA_BY_IDX(DT_PATH(leds), gpios, 0, pin),
|
||||
static const gpio_dt_spec led_gpios[] = {
|
||||
GPIO_DT_SPEC_GET_BY_IDX(DT_PATH(leds), gpios, 0),
|
||||
#if NUM_LED_PINS >= 2
|
||||
DT_PHA_BY_IDX(DT_PATH(leds), gpios, 1, pin),
|
||||
GPIO_DT_SPEC_GET_BY_IDX(DT_PATH(leds), gpios, 1),
|
||||
#endif
|
||||
#if NUM_LED_PINS >= 3
|
||||
DT_PHA_BY_IDX(DT_PATH(leds), gpios, 2, pin),
|
||||
GPIO_DT_SPEC_GET_BY_IDX(DT_PATH(leds), gpios, 2),
|
||||
#endif
|
||||
#if NUM_LED_PINS >= 4
|
||||
DT_PHA_BY_IDX(DT_PATH(leds), gpios, 3, pin),
|
||||
GPIO_DT_SPEC_GET_BY_IDX(DT_PATH(leds), gpios, 3),
|
||||
#endif
|
||||
#if NUM_LED_PINS >= 5
|
||||
DT_PHA_BY_IDX(DT_PATH(leds), gpios, 4, pin),
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* GPIO port labels (for up to 5 LED pins)
|
||||
*/
|
||||
static const char *const led_ports[] = {
|
||||
DT_PROP_BY_PHANDLE_IDX(DT_PATH(leds), gpios, 0, label),
|
||||
#if NUM_LED_PINS >= 2
|
||||
DT_PROP_BY_PHANDLE_IDX(DT_PATH(leds), gpios, 1, label),
|
||||
#endif
|
||||
#if NUM_LED_PINS >= 3
|
||||
DT_PROP_BY_PHANDLE_IDX(DT_PATH(leds), gpios, 2, label),
|
||||
#endif
|
||||
#if NUM_LED_PINS >= 4
|
||||
DT_PROP_BY_PHANDLE_IDX(DT_PATH(leds), gpios, 3, label),
|
||||
#endif
|
||||
#if NUM_LED_PINS >= 5
|
||||
DT_PROP_BY_PHANDLE_IDX(DT_PATH(leds), gpios, 4, label),
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* GPIO pin flags (for up to 5 LED pins)
|
||||
*/
|
||||
static const gpio_flags_t led_flags[] = {
|
||||
DT_PHA_BY_IDX(DT_PATH(leds), gpios, 0, flags),
|
||||
#if NUM_LED_PINS >= 2
|
||||
DT_PHA_BY_IDX(DT_PATH(leds), gpios, 1, flags),
|
||||
#endif
|
||||
#if NUM_LED_PINS >= 3
|
||||
DT_PHA_BY_IDX(DT_PATH(leds), gpios, 2, flags),
|
||||
#endif
|
||||
#if NUM_LED_PINS >= 4
|
||||
DT_PHA_BY_IDX(DT_PATH(leds), gpios, 3, flags),
|
||||
#endif
|
||||
#if NUM_LED_PINS >= 5
|
||||
DT_PHA_BY_IDX(DT_PATH(leds), gpios, 4, flags),
|
||||
GPIO_DT_SPEC_GET_BY_IDX(DT_PATH(leds), gpios, 4),
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -132,12 +96,14 @@ void leds_update_thread()
|
||||
unsigned int led_count = 0;
|
||||
int flicker_count = 0;
|
||||
bool flicker_state = true;
|
||||
const struct device *led_devs[NUM_LED_PINS];
|
||||
|
||||
int wdt_channel = task_wdt_add(1000, task_wdt_callback, (void *)k_current_get());
|
||||
|
||||
for (int pin = 0; pin < NUM_LED_PINS; pin++) {
|
||||
led_devs[pin] = device_get_binding(led_ports[pin]);
|
||||
if (!device_is_ready(led_gpios[pin].port)) {
|
||||
printf("LED %d not ready\n", pin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
leds_init(true);
|
||||
@@ -164,17 +130,13 @@ void leds_update_thread()
|
||||
for (unsigned int pin_number = 0; pin_number < NUM_LED_PINS; pin_number++) {
|
||||
switch (led_pin_states[led_count][pin_number]) {
|
||||
case PIN_HIGH:
|
||||
gpio_pin_configure(led_devs[pin_number], led_pins[pin_number],
|
||||
led_flags[pin_number] | GPIO_OUTPUT);
|
||||
gpio_pin_set(led_devs[pin_number], led_pins[pin_number], 1);
|
||||
gpio_pin_configure_dt(&led_gpios[pin_number], GPIO_OUTPUT_ACTIVE);
|
||||
break;
|
||||
case PIN_LOW:
|
||||
gpio_pin_configure(led_devs[pin_number], led_pins[pin_number],
|
||||
led_flags[pin_number] | GPIO_OUTPUT);
|
||||
gpio_pin_set(led_devs[pin_number], led_pins[pin_number], 0);
|
||||
gpio_pin_configure_dt(&led_gpios[pin_number], GPIO_OUTPUT_INACTIVE);
|
||||
break;
|
||||
case PIN_FLOAT:
|
||||
gpio_pin_configure(led_devs[pin_number], led_pins[pin_number], GPIO_INPUT);
|
||||
gpio_pin_configure_dt(&led_gpios[pin_number], GPIO_INPUT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -182,7 +144,7 @@ void leds_update_thread()
|
||||
else {
|
||||
// all pins floating
|
||||
for (unsigned int pin_number = 0; pin_number < NUM_LED_PINS; pin_number++) {
|
||||
gpio_pin_configure(led_devs[pin_number], led_pins[pin_number], GPIO_INPUT);
|
||||
gpio_pin_configure_dt(&led_gpios[pin_number], GPIO_INPUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
/*
|
||||
* Find out if LED was specified in board devicetree file
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
#include "load.h"
|
||||
|
||||
#include "board.h"
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#if BOARD_HAS_LOAD_OUTPUT || UNIT_TEST
|
||||
|
||||
|
||||
+27
-25
@@ -8,10 +8,10 @@
|
||||
|
||||
#ifdef CONFIG_SOC_FAMILY_STM32
|
||||
|
||||
#include <device.h>
|
||||
#include <drivers/gpio.h>
|
||||
#include <drivers/pwm.h>
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/drivers/pwm.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "hardware.h"
|
||||
@@ -21,14 +21,16 @@
|
||||
#include <stm32_ll_bus.h>
|
||||
#include <stm32_ll_system.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if BOARD_HAS_LOAD_OUTPUT
|
||||
#define LOAD_GPIO DT_CHILD(DT_PATH(outputs), load)
|
||||
static const struct device *dev_load;
|
||||
#define LOAD_NODE DT_CHILD(DT_PATH(outputs), load)
|
||||
static const struct gpio_dt_spec load_switch = GPIO_DT_SPEC_GET(LOAD_NODE, gpios);
|
||||
#endif
|
||||
|
||||
#if BOARD_HAS_USB_OUTPUT
|
||||
#define USB_GPIO DT_CHILD(DT_PATH(outputs), usb_pwr)
|
||||
static const struct device *dev_usb;
|
||||
#define USB_NODE DT_CHILD(DT_PATH(outputs), usb_pwr)
|
||||
static const struct gpio_dt_spec usb_switch = GPIO_DT_SPEC_GET(USB_NODE, gpios);
|
||||
#endif
|
||||
|
||||
// short circuit detection comparator only present in PWM 2420 LUS board so far
|
||||
@@ -145,17 +147,20 @@ void load_out_set(bool status)
|
||||
#endif
|
||||
|
||||
#if BOARD_HAS_LOAD_OUTPUT
|
||||
gpio_pin_configure(dev_load, DT_GPIO_PIN(LOAD_GPIO, gpios),
|
||||
DT_GPIO_FLAGS(LOAD_GPIO, gpios) | GPIO_OUTPUT_INACTIVE);
|
||||
if (!device_is_ready(load_switch.port)) {
|
||||
printf("Load switch GPIO not ready\n");
|
||||
return;
|
||||
}
|
||||
gpio_pin_configure_dt(&load_switch, GPIO_OUTPUT_INACTIVE);
|
||||
if (status == true) {
|
||||
#ifdef CONFIG_BOARD_PWM_2420_LUS
|
||||
lptim_init();
|
||||
#else
|
||||
gpio_pin_set(dev_load, DT_GPIO_PIN(LOAD_GPIO, gpios), 1);
|
||||
gpio_pin_set_dt(&load_switch, 1);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
gpio_pin_set(dev_load, DT_GPIO_PIN(LOAD_GPIO, gpios), 0);
|
||||
gpio_pin_set_dt(&load_switch, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -163,17 +168,20 @@ void load_out_set(bool status)
|
||||
void usb_out_set(bool status)
|
||||
{
|
||||
#if BOARD_HAS_USB_OUTPUT
|
||||
gpio_pin_configure(dev_usb, DT_GPIO_PIN(USB_GPIO, gpios),
|
||||
DT_GPIO_FLAGS(USB_GPIO, gpios) | GPIO_OUTPUT_INACTIVE);
|
||||
if (!device_is_ready(usb_switch.port)) {
|
||||
printf("USB switch GPIO not ready\n");
|
||||
return;
|
||||
}
|
||||
gpio_pin_configure_dt(&usb_switch, GPIO_OUTPUT_INACTIVE);
|
||||
if (status == true) {
|
||||
gpio_pin_set(dev_usb, DT_GPIO_PIN(USB_GPIO, gpios), 1);
|
||||
gpio_pin_set_dt(&usb_switch, 1);
|
||||
#if DT_PROP(DT_CHILD(DT_PATH(outputs), usb_pwr), latching_pgood)
|
||||
k_sleep(K_MSEC(50));
|
||||
gpio_pin_configure(dev_usb, DT_GPIO_PIN(USB_GPIO, gpios), GPIO_INPUT);
|
||||
gpio_pin_configure_dt(&usb_switch, GPIO_INPUT);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
gpio_pin_set(dev_usb, DT_GPIO_PIN(USB_GPIO, gpios), 0);
|
||||
gpio_pin_set_dt(&usb_switch, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -198,10 +206,6 @@ void load_cp_enable()
|
||||
|
||||
void load_out_init()
|
||||
{
|
||||
#if BOARD_HAS_LOAD_OUTPUT
|
||||
dev_load = device_get_binding(DT_GPIO_LABEL(LOAD_GPIO, gpios));
|
||||
#endif
|
||||
|
||||
// analog comparator to detect short circuits and trigger immediate load switch-off
|
||||
#ifdef CONFIG_BOARD_PWM_2420_LUS
|
||||
short_circuit_comp_init();
|
||||
@@ -215,15 +219,13 @@ void load_out_init()
|
||||
|
||||
void usb_out_init()
|
||||
{
|
||||
#if BOARD_HAS_USB_OUTPUT
|
||||
dev_usb = device_get_binding(DT_GPIO_LABEL(USB_GPIO, gpios));
|
||||
#endif
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
bool pgood_check()
|
||||
{
|
||||
#if BOARD_HAS_USB_OUTPUT
|
||||
return gpio_pin_get(dev_usb, DT_GPIO_PIN(USB_GPIO, gpios));
|
||||
return gpio_pin_get_dt(&usb_switch);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
+6
-6
@@ -6,11 +6,11 @@
|
||||
|
||||
#ifndef UNIT_TEST
|
||||
|
||||
#include <device.h>
|
||||
#include <drivers/gpio.h>
|
||||
#include <stdio.h>
|
||||
#include <task_wdt/task_wdt.h>
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/task_wdt/task_wdt.h>
|
||||
|
||||
#include "helper.h"
|
||||
#include "setup.h"
|
||||
@@ -28,13 +28,13 @@
|
||||
#include "load.h" // load and USB output management
|
||||
#include "pwm_switch.h" // PWM charge controller
|
||||
|
||||
void main(void)
|
||||
int main(void)
|
||||
{
|
||||
printf("Hardware: Libre Solar %s (%s)\n", DT_PROP(DT_PATH(pcb), type),
|
||||
DT_PROP(DT_PATH(pcb), version_str));
|
||||
printf("Firmware: %s\n", FIRMWARE_VERSION_ID);
|
||||
|
||||
task_wdt_init(device_get_binding(DT_LABEL(DT_NODELABEL(iwdg))));
|
||||
task_wdt_init(DEVICE_DT_GET_OR_NULL(DT_NODELABEL(iwdg)));
|
||||
|
||||
setup();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "pwm_switch.h"
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "pwm_switch.h"
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
@@ -24,8 +24,8 @@
|
||||
#include <stm32_ll_rcc.h>
|
||||
#include <stm32_ll_tim.h>
|
||||
|
||||
#include <drivers/pinctrl.h>
|
||||
#include <soc.h>
|
||||
#include <zephyr/drivers/pinctrl.h>
|
||||
|
||||
// all PWM charge controllers use TIM3 at the moment
|
||||
static TIM_TypeDef *tim = TIM3;
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@
|
||||
* @brief Setup of ports and other essential charge controller objects
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include "thingset.h" // handles access to internal data via communication interfaces
|
||||
|
||||
@@ -85,7 +85,7 @@ uint32_t timestamp;
|
||||
#ifndef UNIT_TEST
|
||||
|
||||
#include <soc.h>
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
static inline void timestamp_inc(struct k_timer *timer_id)
|
||||
{
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -265,11 +265,11 @@
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
clock-frequency = <I2C_BITRATE_STANDARD>;
|
||||
eeprom@50 {
|
||||
|
||||
eeprom: eeprom@50 {
|
||||
// Microchip 24AA32A
|
||||
compatible = "atmel,at24";
|
||||
reg = <0x50>;
|
||||
label = "EEPROM_0";
|
||||
size = <32768>;
|
||||
pagesize = <32>;
|
||||
address-width = <16>;
|
||||
|
||||
@@ -197,11 +197,11 @@
|
||||
pinctrl-0 = <&i2c2_scl_pb10 &i2c2_sda_pb11>;
|
||||
pinctrl-names = "default";
|
||||
clock-frequency = <I2C_BITRATE_STANDARD>;
|
||||
eeprom@50 {
|
||||
|
||||
eeprom: eeprom@50 {
|
||||
// Microchip 24AA32A
|
||||
compatible = "atmel,at24";
|
||||
reg = <0x50>;
|
||||
label = "EEPROM_0";
|
||||
size = <32768>;
|
||||
pagesize = <32>; // 24AA01: 8 bytes
|
||||
address-width = <16>; // 24AA01: 8 bit
|
||||
|
||||
@@ -206,11 +206,11 @@
|
||||
pinctrl-0 = <&i2c1_scl_pa15 &i2c1_sda_pb7>;
|
||||
pinctrl-names = "default";
|
||||
clock-frequency = <I2C_BITRATE_STANDARD>;
|
||||
eeprom@50 {
|
||||
|
||||
eeprom: eeprom@50 {
|
||||
// Microchip 24AA32A
|
||||
compatible = "atmel,at24";
|
||||
reg = <0x50>;
|
||||
label = "EEPROM_0";
|
||||
size = <32768>;
|
||||
pagesize = <32>;
|
||||
address-width = <16>;
|
||||
|
||||
@@ -8,9 +8,6 @@ compatible: "zephyr,dummy-pwm"
|
||||
include: [pwm-controller.yaml, base.yaml]
|
||||
|
||||
properties:
|
||||
label:
|
||||
required: true
|
||||
|
||||
"#pwm-cells":
|
||||
const: 3
|
||||
|
||||
|
||||
@@ -149,7 +149,6 @@
|
||||
|
||||
pwm3: pwm3 {
|
||||
compatible = "zephyr,dummy-pwm";
|
||||
label = "PWM_3";
|
||||
#pwm-cells = <3>;
|
||||
};
|
||||
};
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@
|
||||
#include "unity.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <device.h>
|
||||
#include <zephyr.h>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#ifdef CONFIG_ARCH_POSIX
|
||||
#include "posix_board_if.h"
|
||||
|
||||
@@ -10,8 +10,8 @@ manifest:
|
||||
url-base: https://github.com/ThrowTheSwitch
|
||||
projects:
|
||||
- name: zephyr
|
||||
remote: zephyrproject
|
||||
revision: v3.1-branch
|
||||
remote: libresolar
|
||||
revision: v3.2-branch
|
||||
import:
|
||||
name-allowlist:
|
||||
- cmsis
|
||||
@@ -19,11 +19,11 @@ manifest:
|
||||
- hal_stm32
|
||||
- name: oled-display-library
|
||||
remote: libresolar
|
||||
revision: cc3033c0daace8cb50ab0e6406a9498cc81cdb39
|
||||
revision: 523b26c103de56714fcda655702d600870a671bc
|
||||
path: modules/oled-display
|
||||
- name: thingset-device-library
|
||||
remote: thingset
|
||||
revision: 5c2b562d77cd44969c822bbd8c37cd7394d5ca58
|
||||
revision: 1c4ca10b12620b1a70bbbcea6b2d4724289b9678
|
||||
path: modules/thingset
|
||||
- name: unity
|
||||
remote: throwtheswitch
|
||||
|
||||
Reference in New Issue
Block a user