USB CDC

Three connection methods of the console:

  1. IP network

  2、USB

  3、UART

  

Introduce the USB CDC method:

  

1. The console configuration is as follows:

  

2、USB

    Product ID can be: 0x0000/0x5300/0x0238

    Different values ​​represent different COM ports

  

3. CDC configuration

  

 

 

#include "g_testThread.h"

void led_toggle_callback(sf_console_cb_args_t * p_args);

const sf_console_command_t g_sf_console_commands[] =
{
 { .command = (uint8_t *)"TOGGLE",              //CMD
   .help = (uint8_t *)"Toggle an LED",
   .callback = led_toggle_callback,              // console command callback.context 
   =   NULL
 },
};

/* 1. Create Menu Structure */
const sf_console_menu_t g_sf_console_root_menu =
{
 .menu_prev = NULL,
 .menu_name = (uint8_t *)"Command",
 .num_commands = (sizeof(g_sf_console_commands)) / (sizeof(g_sf_console_commands[0])),
 .command_list = &g_sf_console_commands[0]
};

/***********************************************************************************************************************
* Function Name: led_toggle_callback
* Description  : Implement Callbacks
*                   Callback function provided to g_sf_console_commands[0]. Function is invoked when user inputs
*                   TOGGLE<CR> in the Console
* Arguments    : p_args -
*                   Pointer to an instance type sf_console_cb_args_t
* Return Value : None
***********************************************************************************************************************/
void led_toggle_callback(sf_console_cb_args_t * p_args)
{
    bsp_leds_t leds;
    ioport_level_t level;

    /* Get LED list from BSP */
    R_BSP_LedsGet(&leds);

    /* Read current level */
    g_ioport.p_api->pinRead(leds.p_leds[0], &level);

    /* Invert level */
    g_ioport.p_api->pinWrite(leds.p_leds[0], (ioport_level_t)!level);
}

/* Test Thread entry function */
void g_testThread_entry(void)
{
    /* TODO: add your own code here */
    while (1)
    {
        g_sf_console0.p_api->prompt(g_sf_console0.p_ctrl, NULL, TX_NO_WAIT);//TX_WAIT_FOREVER
        //tx_thread_sleep (1);
    }
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325163692&siteId=291194637
usb
usb