reverted un-related file changes

This commit is contained in:
hathach 2024-04-05 17:04:33 +07:00
parent 18a458679f
commit caf2c5e0b7
No known key found for this signature in database
GPG Key ID: 26FAB84F615C3C52
13 changed files with 54 additions and 39 deletions

View File

@ -52,7 +52,8 @@
#define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1)
#endif
#define CDC_STACK_SZIE configMINIMAL_STACK_SIZE
#define CDC_STACK_SIZE configMINIMAL_STACK_SIZE
#define BLINKY_STACK_SIZE configMINIMAL_STACK_SIZE
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTOTYPES
@ -69,21 +70,22 @@ enum {
BLINK_SUSPENDED = 2500,
};
// static timer & task
// static task
#if configSUPPORT_STATIC_ALLOCATION
StaticTimer_t blinky_tmdef;
StackType_t blinky_stack[BLINKY_STACK_SIZE];
StaticTask_t blinky_taskdef;
StackType_t usb_device_stack[USBD_STACK_SIZE];
StaticTask_t usb_device_taskdef;
StackType_t cdc_stack[CDC_STACK_SZIE];
StackType_t cdc_stack[CDC_STACK_SIZE];
StaticTask_t cdc_taskdef;
#endif
TimerHandle_t blinky_tm;
static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED;
static void led_blinky_cb(TimerHandle_t xTimer);
static void usb_device_task(void *param);
void led_blinking_task(void* param);
void cdc_task(void *params);
//--------------------------------------------------------------------+
@ -94,22 +96,20 @@ int main(void) {
board_init();
#if configSUPPORT_STATIC_ALLOCATION
// soft timer for blinky
blinky_tm = xTimerCreateStatic(NULL, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), true, NULL, led_blinky_cb, &blinky_tmdef);
// blinky task
xTaskCreateStatic(led_blinking_task, "blinky", BLINKY_STACK_SIZE, NULL, 1, blinky_stack, &blinky_taskdef);
// Create a task for tinyusb device stack
xTaskCreateStatic(usb_device_task, "usbd", USBD_STACK_SIZE, NULL, configMAX_PRIORITIES-1, usb_device_stack, &usb_device_taskdef);
// Create CDC task
xTaskCreateStatic(cdc_task, "cdc", CDC_STACK_SZIE, NULL, configMAX_PRIORITIES-2, cdc_stack, &cdc_taskdef);
xTaskCreateStatic(cdc_task, "cdc", CDC_STACK_SIZE, NULL, configMAX_PRIORITIES - 2, cdc_stack, &cdc_taskdef);
#else
blinky_tm = xTimerCreate(NULL, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), true, NULL, led_blinky_cb);
xTaskCreate(led_blinking_task, "blinky", BLINKY_STACK_SIZE, NULL, 1, NULL);
xTaskCreate(usb_device_task, "usbd", USBD_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL);
xTaskCreate(cdc_task, "cdc", CDC_STACK_SZIE, NULL, configMAX_PRIORITIES - 2, NULL);
#endif
xTimerStart(blinky_tm, 0);
// skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
#if !TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
vTaskStartScheduler();
@ -154,12 +154,12 @@ static void usb_device_task(void *param) {
// Invoked when device is mounted
void tud_mount_cb(void) {
xTimerChangePeriod(blinky_tm, pdMS_TO_TICKS(BLINK_MOUNTED), 0);
blink_interval_ms = BLINK_MOUNTED;
}
// Invoked when device is unmounted
void tud_umount_cb(void) {
xTimerChangePeriod(blinky_tm, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), 0);
blink_interval_ms = BLINK_NOT_MOUNTED;
}
// Invoked when usb bus is suspended
@ -167,16 +167,12 @@ void tud_umount_cb(void) {
// Within 7ms, device must draw an average of current less than 2.5 mA from bus
void tud_suspend_cb(bool remote_wakeup_en) {
(void) remote_wakeup_en;
xTimerChangePeriod(blinky_tm, pdMS_TO_TICKS(BLINK_SUSPENDED), 0);
blink_interval_ms = BLINK_SUSPENDED;
}
// Invoked when usb bus is resumed
void tud_resume_cb(void) {
if (tud_mounted()) {
xTimerChangePeriod(blinky_tm, pdMS_TO_TICKS(BLINK_MOUNTED), 0);
} else {
xTimerChangePeriod(blinky_tm, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), 0);
}
blink_interval_ms = tud_mounted() ? BLINK_MOUNTED : BLINK_NOT_MOUNTED;
}
//--------------------------------------------------------------------+
@ -235,10 +231,17 @@ void tud_cdc_rx_cb(uint8_t itf) {
//--------------------------------------------------------------------+
// BLINKING TASK
//--------------------------------------------------------------------+
static void led_blinky_cb(TimerHandle_t xTimer) {
(void) xTimer;
void led_blinking_task(void* param) {
(void) param;
static uint32_t start_ms = 0;
static bool led_state = false;
while (1) {
// Blink every interval ms
vTaskDelay(blink_interval_ms / portTICK_PERIOD_MS);
start_ms += blink_interval_ms;
board_led_write(led_state);
led_state = 1 - led_state; // toggle
}
}

View File

@ -8,9 +8,6 @@ CFLAGS += -Wno-error=unused-parameter -Wno-error=redundant-decls -Wno-error=cast
# All source paths should be relative to the top level.
LD_FILE = $(MCU_DIR)/gcc/K32L2A41xxxxA_flash.ld
SRC_C += \
$(MCU_DIR)/project_template/clock_config.c \
# For flash-jlink target
JLINK_DEVICE = K32L2A41xxxxA

View File

@ -8,9 +8,6 @@ CFLAGS += -Wno-error=unused-parameter -Wno-error=redundant-decls
# All source paths should be relative to the top level.
LD_FILE = $(MCU_DIR)/gcc/K32L2B31xxxxA_flash.ld
SRC_C += \
$(MCU_DIR)/project_template/clock_config.c \
# For flash-jlink target
JLINK_DEVICE = K32L2B31xxxxA

View File

@ -42,8 +42,8 @@
#define BUTTON_STATE_ACTIVE 0
// UART
#define UART_RX_PIN 32
#define UART_TX_PIN 33
#define UART_RX_PIN 22
#define UART_TX_PIN 20
// SPI for USB host shield
// Pin is correct but not working probably due to signal incompatible (1.8V 3v3) with MAC3421E !?

View File

@ -2,6 +2,9 @@ CPU_CORE = cortex-m33
MCU_VARIANT = nrf5340_application
CFLAGS += -DNRF5340_XXAA -DNRF5340_XXAA_APPLICATION
# enable max3421 host driver for this board
MAX3421_HOST = 1
LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf5340_xxaa_application.ld
SRC_C += hw/mcu/nordic/nrfx/drivers/src/nrfx_usbreg.c

View File

@ -76,6 +76,7 @@ enum {
#define LFCLK_SRC_RC CLOCK_LFCLKSRC_SRC_LFRC
#define VBUSDETECT_Msk USBREG_USBREGSTATUS_VBUSDETECT_Msk
#define OUTPUTRDY_Msk USBREG_USBREGSTATUS_OUTPUTRDY_Msk
#define GPIOTE_IRQn GPIOTE1_IRQn
#else
#define LFCLK_SRC_RC CLOCK_LFCLKSRC_SRC_RC
#define VBUSDETECT_Msk POWER_USBREGSTATUS_VBUSDETECT_Msk

View File

@ -203,7 +203,7 @@ uint8_t rdwr10_validate_cmd(msc_cbw_t const* cbw)
//--------------------------------------------------------------------+
// Debug
//--------------------------------------------------------------------+
#if CFG_TUSB_DEBUG >= 2
#if CFG_TUSB_DEBUG >= CFG_TUD_MSC_LOG_LEVEL
TU_ATTR_UNUSED tu_static tu_lookup_entry_t const _msc_scsi_cmd_lookup[] =
{

View File

@ -369,6 +369,8 @@ typedef struct TU_ATTR_PACKED {
uint8_t bCopyProtect;
} tusb_desc_video_format_uncompressed_t;
TU_VERIFY_STATIC(sizeof(tusb_desc_video_format_uncompressed_t) == 27, "size is not correct");
// Uncompressed payload specs: 3.1.2 frame descriptor
#define tusb_desc_video_frame_uncompressed_nint_t(_nint) \
struct TU_ATTR_PACKED { \
@ -382,7 +384,7 @@ typedef struct TU_ATTR_PACKED {
uint32_t dwMinBitRate; \
uint32_t dwMaxBitRate; \
uint32_t dwMaxVideoFrameBufferSize; /* deprecated in 1.5 */ \
uint32_t dwDefaultFrameInterval; \
uint32_t dwDefaultFrameInterval; /* 100ns unit */\
uint8_t bFrameIntervalType; \
uint32_t dwFrameInterval[_nint]; \
}
@ -414,6 +416,8 @@ typedef struct TU_ATTR_PACKED {
uint8_t bCopyProtect;
} tusb_desc_video_format_mjpeg_t;
TU_VERIFY_STATIC(sizeof(tusb_desc_video_format_mjpeg_t) == 11, "size is not correct");
// MJPEG payload specs: 3.1.2 frame descriptor (same as uncompressed)
typedef tusb_desc_video_frame_uncompressed_t tusb_desc_video_frame_mjpeg_t;
typedef tusb_desc_video_frame_uncompressed_1int_t tusb_desc_video_frame_mjpeg_1int_t;

View File

@ -60,6 +60,7 @@ void tu_print_mem(void const *buf, uint32_t count, uint8_t indent);
static inline void tu_print_buf(uint8_t const* buf, uint32_t bufsize) {
for(uint32_t i=0; i<bufsize; i++) tu_printf("%02X ", buf[i]);
tu_printf("\r\n");
}
// Log with Level
@ -76,7 +77,7 @@ static inline void tu_print_buf(uint8_t const* buf, uint32_t bufsize) {
#define TU_LOG1_MEM tu_print_mem
#define TU_LOG1_BUF(_x, _n) tu_print_buf((uint8_t const*)(_x), _n)
#define TU_LOG1_INT(_x) tu_printf(#_x " = %ld\r\n", (unsigned long) (_x) )
#define TU_LOG1_HEX(_x) tu_printf(#_x " = %lX\r\n", (unsigned long) (_x) )
#define TU_LOG1_HEX(_x) tu_printf(#_x " = 0x%lX\r\n", (unsigned long) (_x) )
// Log Level 2: Warn
#if CFG_TUSB_DEBUG >= 2

View File

@ -224,6 +224,7 @@ static void _ff_push_n(tu_fifo_t* f, void const * app_buf, uint16_t n, uint16_t
if (wrap_bytes > 0) _ff_push_const_addr(ff_buf, app_buf, wrap_bytes);
}
break;
default: break;
}
}

View File

@ -36,6 +36,10 @@
#endif
#define TU_LOG_USBH(...) TU_LOG(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
#define TU_LOG_MEM_USBH(...) TU_LOG_MEM(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
#define TU_LOG_BUF_USBH(...) TU_LOG_BUF(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
#define TU_LOG_INT_USBH(...) TU_LOG_INT(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
#define TU_LOG_HEX_USBH(...) TU_LOG_HEX(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
enum {
USBH_EPSIZE_BULK_MAX = (TUH_OPT_HIGH_SPEED ? TUSB_EPSIZE_BULK_HS : TUSB_EPSIZE_BULK_FS)

View File

@ -653,8 +653,12 @@ void dcd_int_handler(uint8_t rhport)
if (NRF_USBD->EPOUTEN & USBD_EPOUTEN_ISOOUT_Msk)
{
iso_enabled = true;
// Transfer from endpoint to RAM only if data is not corrupted
if ((int_status & USBD_INTEN_USBEVENT_Msk) == 0 ||
(NRF_USBD->EVENTCAUSE & USBD_EVENTCAUSE_ISOOUTCRC_Msk) == 0) {
xact_out_dma(EP_ISO_NUM);
}
}
// ISOIN: Notify client that data was transferred
if (NRF_USBD->EPINEN & USBD_EPINEN_ISOIN_Msk)
@ -683,7 +687,7 @@ void dcd_int_handler(uint8_t rhport)
{
TU_LOG(3, "EVENTCAUSE = 0x%04lX\r\n", NRF_USBD->EVENTCAUSE);
enum { EVT_CAUSE_MASK = USBD_EVENTCAUSE_SUSPEND_Msk | USBD_EVENTCAUSE_RESUME_Msk | USBD_EVENTCAUSE_USBWUALLOWED_Msk };
enum { EVT_CAUSE_MASK = USBD_EVENTCAUSE_SUSPEND_Msk | USBD_EVENTCAUSE_RESUME_Msk | USBD_EVENTCAUSE_USBWUALLOWED_Msk | USBD_EVENTCAUSE_ISOOUTCRC_Msk };
uint32_t const evt_cause = NRF_USBD->EVENTCAUSE & EVT_CAUSE_MASK;
NRF_USBD->EVENTCAUSE = evt_cause; // clear interrupt

View File

@ -83,7 +83,7 @@ typedef struct TU_ATTR_ALIGNED(16)
volatile uint32_t condition_code : 4;
// Word 1
volatile uint8_t* current_buffer_pointer;
uint8_t* volatile current_buffer_pointer;
// Word 2 : next TD
volatile uint32_t next;