Skip to content

Commit

Permalink
Fix for overriding UART0 pins, reverted and fixed tests for ESP32-S3 …
Browse files Browse the repository at this point in the history
…conditional code.
  • Loading branch information
terjeio committed Oct 23, 2024
1 parent ace5395 commit fe63c52
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
12 changes: 6 additions & 6 deletions main/ioports_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static wait_on_input_ptr wait_on_input_digital;

#if AUX_ANALOG_IN

#ifdef CONFIG_IDF_TARGET_ESP32
#if CONFIG_IDF_TARGET_ESP32

static const adc_map_t adc_map[] = {
{ ADC1_CHANNEL_0, GPIO_NUM_36 },
Expand All @@ -74,7 +74,7 @@ static const adc_map_t adc_map[] = {
{ ADC1_CHANNEL_7, GPIO_NUM_35 }
};

#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#elif CONFIG_IDF_TARGET_ESP32S3

static const adc_map_t adc_map[] = {
{ ADC1_CHANNEL_0, GPIO_NUM_1 },
Expand Down Expand Up @@ -173,7 +173,7 @@ static bool init_pwm0 (xbar_t *pin, pwm_config_t *config, bool persistent)
ledc_channel_config_t *ch_config = &pwm_out[ch].ch_config;

static ledc_timer_config_t pwm_timer = {
#ifdef CONFIG_IDF_TARGET_ESP32S3
#if CONFIG_IDF_TARGET_ESP32S3
.speed_mode = LEDC_LOW_SPEED_MODE,
#else
.speed_mode = LEDC_HIGH_SPEED_MODE,
Expand All @@ -188,7 +188,7 @@ static bool init_pwm0 (xbar_t *pin, pwm_config_t *config, bool persistent)
init_ok = true;

ch_config->gpio_num = AUXOUTPUT0_PWM_PIN,
#ifdef CONFIG_IDF_TARGET_ESP32S3
#if CONFIG_IDF_TARGET_ESP32S3
ch_config->speed_mode = LEDC_SPEED_MODE_MAX;
#else
ch_config->speed_mode = LEDC_HIGH_SPEED_MODE;
Expand Down Expand Up @@ -252,7 +252,7 @@ static bool init_pwm1 (xbar_t *pin, pwm_config_t *config, bool persistent)
ledc_channel_config_t *ch_config = &pwm_out[ch].ch_config;

static ledc_timer_config_t pwm_timer = {
#ifdef CONFIG_IDF_TARGET_ESP32S3
#if CONFIG_IDF_TARGET_ESP32S3
.speed_mode = LEDC_LOW_SPEED_MODE,
#else
.speed_mode = LEDC_HIGH_SPEED_MODE,
Expand All @@ -267,7 +267,7 @@ static bool init_pwm1 (xbar_t *pin, pwm_config_t *config, bool persistent)
init_ok = true;

ch_config->gpio_num = AUXOUTPUT1_PWM_PIN,
#ifdef CONFIG_IDF_TARGET_ESP32S3
#if CONFIG_IDF_TARGET_ESP32S3
ch_config->speed_mode = LEDC_SPEED_MODE_MAX;
#else
ch_config->speed_mode = LEDC_HIGH_SPEED_MODE;
Expand Down
2 changes: 1 addition & 1 deletion main/my_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// Configuration
// Uncomment to enable, for some a value > 1 may be assigned, if so the default value is shown.

#ifdef CONFIG_IDF_TARGET_ESP32S3
#if CONFIG_IDF_TARGET_ESP32S3
#define USB_SERIAL_CDC 1 // Serial communication via native USB.
#endif

Expand Down
29 changes: 15 additions & 14 deletions main/uart_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#if !defined(CONFIG_IDF_TARGET_ESP32S3)
#if !CONFIG_IDF_TARGET_ESP32S3
#include "esp32/rom/ets_sys.h"
#include "esp32/rom/uart.h"
#endif
Expand Down Expand Up @@ -56,7 +56,7 @@
#define UART_INTR_SOURCE(u) ((u==0)?ETS_UART0_INTR_SOURCE:( (u==1)?ETS_UART1_INTR_SOURCE:((u==2)?ETS_UART2_INTR_SOURCE:0)))


#ifdef CONFIG_IDF_TARGET_ESP32S3
#if CONFIG_IDF_TARGET_ESP32S3
#ifndef UART_RX_PIN
#define UART_RX_PIN 44
#endif
Expand All @@ -75,7 +75,7 @@
typedef void (*uart_isr_ptr)(void *arg);

typedef struct {
#ifdef CONFIG_IDF_TARGET_ESP32S3
#if CONFIG_IDF_TARGET_ESP32S3
uart_dev_t *dev;
#else
volatile uart_dev_t *dev;
Expand Down Expand Up @@ -282,7 +282,7 @@ static void uartConfig (uart_t *uart, uint32_t baud_rate)
// uart->tx_len = 128;
uart_ll_set_mode(uart->dev, UART_MODE_UART);

#ifdef CONFIG_IDF_TARGET_ESP32S3
#if CONFIG_IDF_TARGET_ESP32S3

periph_module_reset((periph_module_t)(PERIPH_UART0_MODULE + uart->num));
periph_module_enable((periph_module_t)(PERIPH_UART0_MODULE + uart->num));
Expand Down Expand Up @@ -317,23 +317,24 @@ static void uartConfig (uart_t *uart, uint32_t baud_rate)

// Note: UART0 pin mappings are set at boot, no need to set here unless override is required

#if SERIAL2_ENABLE || SERIAL3_ENABLE

switch(uart->num) {
#ifdef CONFIG_IDF_TARGET_ESP32S3
#if CONFIG_IDF_TARGET_ESP32S3
#if UART_RX_PIN != 44 || UART_TX_PIN != 43
case 0:
uart_set_pin(uart->num, UART_TX_PIN, UART_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
break;
#define UART0_PINS_REDEFINED
#endif
#else
#if UART_RX_PIN != 34 || UART_TX_PIN != 35
case 0:
uart_set_pin(uart->num, UART_TX_PIN, UART_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
break;
#define UART0_PINS_REDEFINED
#endif
#endif

#if SERIAL2_ENABLE || SERIAL3_ENABLE || defined(UART0_PINS_REDEFINED)

switch(uart->num) {
#ifdef UART0_PINS_REDEFINED
case 0:
uart_set_pin(uart->num, UART_TX_PIN, UART_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
break;
#endif
#if SERIAL2_ENABLE
case 1:
#ifdef UART2_TX_PIN
Expand Down
5 changes: 3 additions & 2 deletions main/usb_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@
*/

#ifdef CONFIG_IDF_TARGET_ESP32S3
#include "sdkconfig.h"

#if CONFIG_IDF_TARGET_ESP32S3

#include <stdint.h>
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "tinyusb.h"
#include "tusb_cdc_acm.h"
#include "sdkconfig.h"

#include <string.h>

Expand Down

0 comments on commit fe63c52

Please sign in to comment.