using usb as console
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <board.h>
|
||||
|
||||
#if 0
|
||||
void usb_dc_low_level_init (uint8_t busid)
|
||||
{
|
||||
extern void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd);
|
||||
HAL_PCD_MspInit(&(PCD_HandleTypeDef){
|
||||
.Instance = USB_OTG_FS
|
||||
});
|
||||
}
|
||||
|
||||
void OTG_FS_IRQHandler (void)
|
||||
{
|
||||
extern void USBD_IRQHandler(uint8_t busid);
|
||||
USBD_IRQHandler(0);
|
||||
}
|
||||
|
||||
int usbd_init(void)
|
||||
{
|
||||
usb_dc_low_level_init(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
INIT_BOARD_EXPORT(usbd_init);
|
||||
|
||||
|
||||
int chrg_usbd_init (void)
|
||||
{
|
||||
extern void cdc_acm_init(uint8_t busid, uintptr_t reg_base);
|
||||
cdc_acm_init(0, USB_OTG_FS_PERIPH_BASE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
//INIT_COMPONENT_EXPORT(chrg_usbd_init);
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <board.h>
|
||||
|
||||
#include "chrg_vcom.h"
|
||||
|
||||
#define DBG_TAG "chrg.vcom"
|
||||
#include <rtdbg.h>
|
||||
|
||||
int chrg_vcom_init (void)
|
||||
{
|
||||
rt_err_t ret = RT_EOK;
|
||||
rt_device_t dev = RT_NULL;
|
||||
|
||||
dev = rt_device_find(DEV_NAME_VCOM);
|
||||
if (RT_NULL == dev) {
|
||||
LOG_E("device 'vcom' not found.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = rt_device_open(dev, RT_DEVICE_FLAG_RDWR);
|
||||
if (RT_EOK != ret) {
|
||||
LOG_E("open 'vcom' failed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//INIT_COMPONENT_EXPORT(chrg_vcom_init);
|
||||
|
||||
|
||||
int chrg_vcom_console_init (void)
|
||||
{
|
||||
rt_console_set_device(DEV_NAME_VCOM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
INIT_ENV_EXPORT(chrg_vcom_console_init);
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef __CHRG_VCOM_H__
|
||||
#define __CHRG_VCOM_H__
|
||||
|
||||
|
||||
#define DEV_NAME_VCOM "vcom"
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <board.h>
|
||||
#include <drv_gpio.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "shell.h"
|
||||
#include "main.h"
|
||||
@@ -21,6 +23,8 @@ void show_app_version (void)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
//rt_uint32_t tick = 0;
|
||||
|
||||
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH)
|
||||
finsh_set_prompt("chrg ");
|
||||
#endif
|
||||
@@ -28,6 +32,8 @@ int main(void)
|
||||
while (1) {
|
||||
rt_thread_mdelay(1000);
|
||||
chrg_wdt_feed();
|
||||
|
||||
//rt_kprintf("%d\r\n", ++tick);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user