USB debugged

This commit is contained in:
AlexeiBazlaev 2020-12-23 00:24:04 +07:00
parent 965b7977b2
commit 7a94a66b74
10 changed files with 341 additions and 326 deletions

Binary file not shown.

View File

@ -577,7 +577,6 @@
<Value>../src/ASF/thirdparty/freertos/freertos-10.0.0/Source/portable/GCC/ARM_CM0</Value>
</ListValues>
</armgcc.compiler.directories.IncludePaths>
<armgcc.compiler.optimization.level>Optimize (-O1)</armgcc.compiler.optimization.level>
<armgcc.compiler.optimization.OtherFlags>-fdata-sections</armgcc.compiler.optimization.OtherFlags>
<armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
<armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>
@ -641,7 +640,7 @@
</ListValues>
</armgcc.assembler.general.IncludePaths>
<armgcc.assembler.debugging.DebugLevel>Default (-g)</armgcc.assembler.debugging.DebugLevel>
<armgcc.preprocessingassembler.general.AssemblerFlags>-DARM_MATH_CM0PLUS=true -DBOARD=SAMD21_XPLAINED_PRO -DEXTINT_CALLBACK_MODE=true -DUDD_ENABLE -DUSART_CALLBACK_MODE=true -DUSB_DEVICE_LPM_SUPPORT -D__SAMD21J18A__ -D__FREERTOS__</armgcc.preprocessingassembler.general.AssemblerFlags>
<armgcc.preprocessingassembler.general.AssemblerFlags>-DARM_MATH_CM0PLUS=true -DBOARD=USER_BOARD -DEXTINT_CALLBACK_MODE=true -DUDD_ENABLE -DUSART_CALLBACK_MODE=true -DUSB_DEVICE_LPM_SUPPORT -D__SAMD21E16B__ -D__FREERTOS__</armgcc.preprocessingassembler.general.AssemblerFlags>
<armgcc.preprocessingassembler.general.IncludePaths>
<ListValues>
<Value>../src</Value>

View File

@ -145,12 +145,12 @@ void ui_com_overflow(void)
void ui_process(uint16_t framenumber)
{
if ((framenumber % 1000) == 0) {
/*if ((framenumber % 1000) == 0) {
LED_On(LED_0_PIN);
}
if ((framenumber % 1000) == 500) {
LED_Off(LED_0_PIN);
}
}*/
}
/**

View File

@ -997,6 +997,7 @@ static inline void usart_unlock(struct usart_module *const module)
* \retval false Peripheral is not busy syncing and can be read/written without
* stalling the bus
*/
//__attribute__((optimize("O0")))
static inline bool usart_is_syncing(
const struct usart_module *const module)
{
@ -1004,12 +1005,12 @@ static inline bool usart_is_syncing(
Assert(module);
Assert(module->hw);
SercomUsart *const usart_hw = &(module->hw->USART);
SercomUsart usart_hw = module->hw->USART;//SercomUsart *const usart_hw = &(module->hw->USART);
uint32_t reg = usart_hw.SYNCBUSY.reg;
#ifdef FEATURE_USART_SYNC_SCHEME_V2
return (usart_hw->SYNCBUSY.reg);
return (reg);
#else
return (usart_hw->STATUS.reg & SERCOM_USART_STATUS_SYNCBUSY);
return (reg & SERCOM_USART_STATUS_SYNCBUSY);
#endif
}

View File

@ -174,10 +174,10 @@ typedef struct _DeviceVectors
/* Cortex-M0+ processor handlers */
void Reset_Handler ( void );
void NMI_Handler ( void );
void HardFault_Handler ( void );
void SVC_Handler ( void );
void PendSV_Handler ( void );
void SysTick_Handler ( void );
//void HardFault_Handler ( void );
//void SVC_Handler ( void );
//void PendSV_Handler ( void );
//void SysTick_Handler ( void );
/* Peripherals handlers */
void PM_Handler ( void );

View File

@ -55,10 +55,10 @@ void Dummy_Handler(void);
/* Cortex-M0+ core handlers */
void NMI_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
//void HardFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
//void SVC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
//void PendSV_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
//void SysTick_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
void HardFault_Handler ( void ) __attribute__ ((weak));
void SVC_Handler ( void ) __attribute__ ((weak));
void PendSV_Handler ( void ) __attribute__ ((weak));
void SysTick_Handler ( void ) __attribute__ ((weak));
/* Peripherals handlers */
void PM_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));

View File

@ -253,7 +253,7 @@ uint32_t ulSetInterruptMaskFromISR( void )
::: "memory"
);
#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#if !defined (__ARMCC_VERSION) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
/* To avoid compiler warnings. The return statement will nevere be reached,
but some compilers warn if it is not included, while others won't compile if
it is. */
@ -270,7 +270,7 @@ void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask )
::: "memory"
);
#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#if !defined (__ARMCC_VERSION) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
/* Just to avoid compiler warning. ulMask is used from the asm code but
the compiler can't see that. Some compilers generate warnings without the
following line, while others generate warnings if the line is included. */

View File

@ -57,8 +57,8 @@
#include <status_codes.h>
// From module: EXTINT - External Interrupt (Callback APIs)
#include <extint.h>
#include <extint_callback.h>
//#include <extint.h>
//#include <extint_callback.h>
// From module: FreeRTOS - kernel 10.0.0
#include <FreeRTOS.h>

View File

@ -62,9 +62,9 @@
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED)
//! USB Device string definitions (Optional)
#define USB_DEVICE_MANUFACTURE_NAME "ATMEL ASF"
#define USB_DEVICE_PRODUCT_NAME "CDC Virtual Com"
// #define USB_DEVICE_SERIAL_NAME "12...EF"
#define USB_DEVICE_MANUFACTURE_NAME "Svyazcom LLC"//"ATMEL ASF"
#define USB_DEVICE_PRODUCT_NAME "RealSense box controller"//"CDC Virtual Com"
#define USB_DEVICE_SERIAL_NAME "00000000"
/**
@ -122,9 +122,9 @@
//! Interface callback definition
#define UDI_CDC_ENABLE_EXT(port) main_cdc_enable(port)
#define UDI_CDC_DISABLE_EXT(port) main_cdc_disable(port)
#define UDI_CDC_RX_NOTIFY(port) uart_rx_notify(port)
#define UDI_CDC_RX_NOTIFY(port) //uart_rx_notify(port)
#define UDI_CDC_TX_EMPTY_NOTIFY(port)
#define UDI_CDC_SET_CODING_EXT(port,cfg) uart_config(port,cfg)
#define UDI_CDC_SET_CODING_EXT(port,cfg) //uart_config(port,cfg)
#define UDI_CDC_SET_DTR_EXT(port,set) main_cdc_set_dtr(port,set)
#define UDI_CDC_SET_RTS_EXT(port,set)

View File

@ -38,6 +38,7 @@
#include "conf_usb.h"
#include "ui.h"
#include "uart.h"
#include <string.h>
static volatile bool main_b_cdc_enable = false;
void prvGetRegistersFromStack (uint32_t *pulFaultStackAddress);
@ -70,7 +71,7 @@ int main(void)
InitTask_cdc_rx_check();
// Init LED
InitTask_led_blink();
ui_init();//ui_powerdown();
//ui_init();//ui_powerdown();
vTaskStartScheduler();
while(true){
@ -80,9 +81,23 @@ int main(void)
void Task_cdc_rx_check(void *parameters)
{
#define PORT0 0
//volatile uint8_t led = 1;
char rcvBuff[128] = {0};
char *pStr = rcvBuff;
int len = 0;
while(true)
{
while(udi_cdc_multi_is_rx_ready(PORT0))
{
len += sprintf(pStr++, "%c", udi_cdc_multi_getc(PORT0));
}
if(len>0)
{
printf("<%s\n", rcvBuff);
len=0;
pStr = rcvBuff;
}
//cdc_rx_check();
/*#if !defined (DEBUG_CPU_IRQ_DISABLE)
@ -120,9 +135,9 @@ void Task_led_blink(void *parameters)
while(1)
{
printf("%u sec\n\r", cnt++);//// stdio_usb_putchar (NULL, "data");//
printf(">%u sec\n\r", 10*(cnt++));//// stdio_usb_putchar (NULL, "data");//
vTaskDelay(10000);
LED_Toggle(LED_PIN);
vTaskDelay(1000);
/*if((c1 % 50000) == 0){
//periodic_event_1s();
if(!stdio_cdc_opened){