usb talking

Release_v1
penguin 4 years ago
parent a6936e53e7
commit 3e291c1791

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,8 @@
#ifndef _ARC_H_
#define _ARC_H_
#include "atmel_start.h"
#endif

@ -145,3 +145,75 @@ r
n n
n n
q q
break serial.c:26
r
c
q
break serial.c:26
r
c
q
break serial.c:26
r
q
break serial.c:26
r
s
n
q
break serial.c:26
r
n
n
n
c
c
r
n
n
n
nq
q
break serial.c:26
r
n
n
n
n
w
q
del 1
break serial.c:28
r
c
c
c
c
q
break serial.c:28
r
c
n
q
info break
break serial.c:34
r
n
n
n
n
q
q
break serial.c:34
r
n
n
n
q
q
break serial.c:34
r
break serial.c:27
r
n
q

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -45,7 +45,8 @@ examples \
hpl/gclk \ hpl/gclk \
usb \ usb \
hpl/core \ hpl/core \
usb/device usb/device \
util
# List the object files # List the object files
OBJS += \ OBJS += \
@ -79,7 +80,8 @@ hal/src/hal_sleep.o \
hpl/dmac/hpl_dmac.o \ hpl/dmac/hpl_dmac.o \
atmel_start.o \ atmel_start.o \
usb/device/usbdc.o \ usb/device/usbdc.o \
hal/src/hal_atomic.o hal/src/hal_atomic.o \
util/serial.o
OBJS_AS_ARGS += \ OBJS_AS_ARGS += \
"hal/src/hal_io.o" \ "hal/src/hal_io.o" \
@ -112,7 +114,8 @@ OBJS_AS_ARGS += \
"hpl/dmac/hpl_dmac.o" \ "hpl/dmac/hpl_dmac.o" \
"atmel_start.o" \ "atmel_start.o" \
"usb/device/usbdc.o" \ "usb/device/usbdc.o" \
"hal/src/hal_atomic.o" "hal/src/hal_atomic.o" \
"util/serial.o"
# List the directories containing header files # List the directories containing header files
DIR_INCLUDES += \ DIR_INCLUDES += \
@ -139,7 +142,8 @@ DIR_INCLUDES += \
-I"../usb/device" \ -I"../usb/device" \
-I"../" \ -I"../" \
-I"../CMSIS/Core/Include" \ -I"../CMSIS/Core/Include" \
-I"../samd21a/include" -I"../samd21a/include" \
-I"../util"
# List the dependency files # List the dependency files
DEPS := $(OBJS:%.o=%.d) DEPS := $(OBJS:%.o=%.d)
@ -175,7 +179,8 @@ DEPS_AS_ARGS += \
"hal/src/hal_atomic.d" \ "hal/src/hal_atomic.d" \
"usb/device/usbdc.d" \ "usb/device/usbdc.d" \
"hpl/pm/hpl_pm.d" \ "hpl/pm/hpl_pm.d" \
"atmel_start.d" "atmel_start.d" \
"util/serial.d"
OUTPUT_FILE_NAME :=ARC-FW OUTPUT_FILE_NAME :=ARC-FW
QUOTE := " QUOTE := "
@ -259,13 +264,7 @@ clean:
rm -f $(OUTPUT_FILE_NAME).a $(OUTPUT_FILE_NAME).hex $(OUTPUT_FILE_NAME).bin \ rm -f $(OUTPUT_FILE_NAME).a $(OUTPUT_FILE_NAME).hex $(OUTPUT_FILE_NAME).bin \
$(OUTPUT_FILE_NAME).lss $(OUTPUT_FILE_NAME).eep $(OUTPUT_FILE_NAME).map \ $(OUTPUT_FILE_NAME).lss $(OUTPUT_FILE_NAME).eep $(OUTPUT_FILE_NAME).map \
$(OUTPUT_FILE_NAME).srec $(OUTPUT_FILE_NAME).srec
clean:
rm -f $(OBJS_AS_ARGS)
rm -f $(OUTPUT_FILE_PATH)
rm -f $(DEPS_AS_ARGS)
rm -f $(OUTPUT_FILE_NAME).a $(OUTPUT_FILE_NAME).hex $(OUTPUT_FILE_NAME).bin \
$(OUTPUT_FILE_NAME).lss $(OUTPUT_FILE_NAME).eep $(OUTPUT_FILE_NAME).map \
$(OUTPUT_FILE_NAME).srec
debug: $(OUTPUT_FILE_NAME).elf debug: $(OUTPUT_FILE_NAME).elf
@$(QUOTE)arm-none-eabi-gdb$(QUOTE) $(OUTPUT_FILE_NAME).elf -x scripts/debug.gdb @$(QUOTE)arm-none-eabi-gdb$(QUOTE) $(OUTPUT_FILE_NAME).elf -x scripts/debug.gdb

File diff suppressed because it is too large Load Diff

@ -83,7 +83,24 @@ main.d main.o: ../main.c ../atmel_start.h ../driver_init.h \
../hal/utils/include/utils_list.h ../usb/usb_protocol.h \ ../hal/utils/include/utils_list.h ../usb/usb_protocol.h \
../usb/usb_includes.h ../config/usbd_config.h \ ../usb/usb_includes.h ../config/usbd_config.h \
../usb/class/cdc/usb_protocol_cdc.h \ ../usb/class/cdc/usb_protocol_cdc.h \
../usb/class/cdc/device/cdcdf_acm_desc.h ../usb/class/cdc/device/cdcdf_acm_desc.h ../util/serial.h \
/usr/arm-none-eabi/include/stdio.h \
/usr/lib/gcc/arm-none-eabi/10.2.0/include/stdarg.h \
/usr/arm-none-eabi/include/sys/types.h \
/usr/arm-none-eabi/include/machine/endian.h \
/usr/arm-none-eabi/include/machine/_endian.h \
/usr/arm-none-eabi/include/sys/select.h \
/usr/arm-none-eabi/include/sys/_sigset.h \
/usr/arm-none-eabi/include/sys/_timeval.h \
/usr/arm-none-eabi/include/sys/timespec.h \
/usr/arm-none-eabi/include/sys/_timespec.h \
/usr/arm-none-eabi/include/sys/_pthreadtypes.h \
/usr/arm-none-eabi/include/sys/sched.h \
/usr/arm-none-eabi/include/machine/types.h \
/usr/arm-none-eabi/include/sys/stdio.h \
/usr/arm-none-eabi/include/stdlib.h \
/usr/arm-none-eabi/include/machine/stdlib.h \
/usr/arm-none-eabi/include/alloca.h
../atmel_start.h: ../atmel_start.h:
../driver_init.h: ../driver_init.h:
../atmel_start_pins.h: ../atmel_start_pins.h:
@ -234,3 +251,21 @@ main.d main.o: ../main.c ../atmel_start.h ../driver_init.h \
../config/usbd_config.h: ../config/usbd_config.h:
../usb/class/cdc/usb_protocol_cdc.h: ../usb/class/cdc/usb_protocol_cdc.h:
../usb/class/cdc/device/cdcdf_acm_desc.h: ../usb/class/cdc/device/cdcdf_acm_desc.h:
../util/serial.h:
/usr/arm-none-eabi/include/stdio.h:
/usr/lib/gcc/arm-none-eabi/10.2.0/include/stdarg.h:
/usr/arm-none-eabi/include/sys/types.h:
/usr/arm-none-eabi/include/machine/endian.h:
/usr/arm-none-eabi/include/machine/_endian.h:
/usr/arm-none-eabi/include/sys/select.h:
/usr/arm-none-eabi/include/sys/_sigset.h:
/usr/arm-none-eabi/include/sys/_timeval.h:
/usr/arm-none-eabi/include/sys/timespec.h:
/usr/arm-none-eabi/include/sys/_timespec.h:
/usr/arm-none-eabi/include/sys/_pthreadtypes.h:
/usr/arm-none-eabi/include/sys/sched.h:
/usr/arm-none-eabi/include/machine/types.h:
/usr/arm-none-eabi/include/sys/stdio.h:
/usr/arm-none-eabi/include/stdlib.h:
/usr/arm-none-eabi/include/machine/stdlib.h:
/usr/arm-none-eabi/include/alloca.h:

Binary file not shown.

Binary file not shown.

@ -0,0 +1,244 @@
util/serial.d util/serial.o: ../util/serial.c ../util/serial.h \
/usr/arm-none-eabi/include/stdio.h /usr/arm-none-eabi/include/_ansi.h \
/usr/arm-none-eabi/include/newlib.h \
/usr/arm-none-eabi/include/_newlib_version.h \
/usr/arm-none-eabi/include/sys/config.h \
/usr/arm-none-eabi/include/machine/ieeefp.h \
/usr/arm-none-eabi/include/sys/features.h \
/usr/arm-none-eabi/include/sys/cdefs.h \
/usr/arm-none-eabi/include/machine/_default_types.h \
/usr/lib/gcc/arm-none-eabi/10.2.0/include/stddef.h \
/usr/lib/gcc/arm-none-eabi/10.2.0/include/stdarg.h \
/usr/arm-none-eabi/include/sys/reent.h \
/usr/arm-none-eabi/include/_ansi.h \
/usr/arm-none-eabi/include/sys/_types.h \
/usr/arm-none-eabi/include/machine/_types.h \
/usr/arm-none-eabi/include/sys/lock.h \
/usr/arm-none-eabi/include/sys/types.h \
/usr/arm-none-eabi/include/sys/_stdint.h \
/usr/arm-none-eabi/include/machine/endian.h \
/usr/arm-none-eabi/include/machine/_endian.h \
/usr/arm-none-eabi/include/sys/select.h \
/usr/arm-none-eabi/include/sys/_sigset.h \
/usr/arm-none-eabi/include/sys/_timeval.h \
/usr/arm-none-eabi/include/sys/timespec.h \
/usr/arm-none-eabi/include/sys/_timespec.h \
/usr/arm-none-eabi/include/sys/_pthreadtypes.h \
/usr/arm-none-eabi/include/sys/sched.h \
/usr/arm-none-eabi/include/machine/types.h \
/usr/arm-none-eabi/include/sys/stdio.h \
/usr/arm-none-eabi/include/stdlib.h \
/usr/arm-none-eabi/include/machine/stdlib.h \
/usr/arm-none-eabi/include/alloca.h /usr/arm-none-eabi/include/string.h \
/usr/arm-none-eabi/include/sys/_locale.h \
/usr/arm-none-eabi/include/strings.h \
/usr/arm-none-eabi/include/sys/string.h ../usb_start.h \
../usb/class/cdc/device/cdcdf_acm.h ../usb/device/usbdc.h \
../usb/usb_includes.h \
/usr/lib/gcc/arm-none-eabi/10.2.0/include/stdbool.h \
/usr/lib/gcc/arm-none-eabi/10.2.0/include/stdint.h \
/usr/arm-none-eabi/include/stdint.h \
/usr/arm-none-eabi/include/sys/_intsup.h ../hal/utils/include/utils.h \
../hal/utils/include/utils_list.h ../hal/utils/include/compiler.h \
../hal/utils/include/parts.h ../samd21a/include/samd21.h \
../samd21a/include/samd21e18a.h ../CMSIS/Core/Include/core_cm0plus.h \
../CMSIS/Core/Include/cmsis_version.h \
../CMSIS/Core/Include/cmsis_compiler.h ../CMSIS/Core/Include/cmsis_gcc.h \
../samd21a/include/system_samd21.h ../samd21a/include/component/ac.h \
../samd21a/include/component/adc.h ../samd21a/include/component/dac.h \
../samd21a/include/component/dmac.h ../samd21a/include/component/dsu.h \
../samd21a/include/component/eic.h ../samd21a/include/component/evsys.h \
../samd21a/include/component/gclk.h \
../samd21a/include/component/hmatrixb.h \
../samd21a/include/component/i2s.h ../samd21a/include/component/mtb.h \
../samd21a/include/component/nvmctrl.h \
../samd21a/include/component/pac.h ../samd21a/include/component/pm.h \
../samd21a/include/component/port.h ../samd21a/include/component/rtc.h \
../samd21a/include/component/sercom.h \
../samd21a/include/component/sysctrl.h ../samd21a/include/component/tc.h \
../samd21a/include/component/tcc.h ../samd21a/include/component/usb.h \
../samd21a/include/component/wdt.h ../samd21a/include/instance/ac.h \
../samd21a/include/instance/adc.h ../samd21a/include/instance/dac.h \
../samd21a/include/instance/dmac.h ../samd21a/include/instance/dsu.h \
../samd21a/include/instance/eic.h ../samd21a/include/instance/evsys.h \
../samd21a/include/instance/gclk.h \
../samd21a/include/instance/sbmatrix.h ../samd21a/include/instance/i2s.h \
../samd21a/include/instance/mtb.h ../samd21a/include/instance/nvmctrl.h \
../samd21a/include/instance/pac0.h ../samd21a/include/instance/pac1.h \
../samd21a/include/instance/pac2.h ../samd21a/include/instance/pm.h \
../samd21a/include/instance/port.h ../samd21a/include/instance/ptc.h \
../samd21a/include/instance/rtc.h ../samd21a/include/instance/sercom0.h \
../samd21a/include/instance/sercom1.h \
../samd21a/include/instance/sercom2.h \
../samd21a/include/instance/sercom3.h \
../samd21a/include/instance/sysctrl.h ../samd21a/include/instance/tc3.h \
../samd21a/include/instance/tc4.h ../samd21a/include/instance/tc5.h \
../samd21a/include/instance/tcc0.h ../samd21a/include/instance/tcc1.h \
../samd21a/include/instance/tcc2.h ../samd21a/include/instance/usb.h \
../samd21a/include/instance/wdt.h ../samd21a/include/pio/samd21e18a.h \
../hri/hri_d21.h ../samd21a/include/sam.h ../hri/hri_ac_d21.h \
../hal/include/hal_atomic.h ../hri/hri_adc_d21.h ../hri/hri_dac_d21.h \
../hri/hri_dmac_d21.h ../hri/hri_dsu_d21.h ../hri/hri_eic_d21.h \
../hri/hri_evsys_d21.h ../hri/hri_gclk_d21.h ../hri/hri_hmatrixb_d21.h \
../hri/hri_i2s_d21.h ../hri/hri_mtb_d21.h ../hri/hri_nvic_d21.h \
../hri/hri_nvmctrl_d21.h ../hri/hri_pac_d21.h ../hri/hri_pm_d21.h \
../hri/hri_port_d21.h ../hri/hri_rtc_d21.h ../hri/hri_sercom_d21.h \
../hri/hri_sysctrl_d21.h ../hri/hri_systemcontrol_d21.h \
../hri/hri_systick_d21.h ../hri/hri_tc_d21.h ../hri/hri_tcc_d21.h \
../hri/hri_usb_d21.h ../hri/hri_wdt_d21.h \
../hal/utils/include/err_codes.h ../hal/utils/include/utils_assert.h \
../usb/usb_protocol.h ../usb/usb_includes.h \
../hal/include/hal_usb_device.h ../hal/include/hpl_usb_device.h \
../hal/include/hpl_usb.h ../config/hpl_usb_config.h \
../config/usbd_config.h ../usb/class/cdc/usb_protocol_cdc.h \
../usb/class/cdc/device/cdcdf_acm_desc.h
../util/serial.h:
/usr/arm-none-eabi/include/stdio.h:
/usr/arm-none-eabi/include/_ansi.h:
/usr/arm-none-eabi/include/newlib.h:
/usr/arm-none-eabi/include/_newlib_version.h:
/usr/arm-none-eabi/include/sys/config.h:
/usr/arm-none-eabi/include/machine/ieeefp.h:
/usr/arm-none-eabi/include/sys/features.h:
/usr/arm-none-eabi/include/sys/cdefs.h:
/usr/arm-none-eabi/include/machine/_default_types.h:
/usr/lib/gcc/arm-none-eabi/10.2.0/include/stddef.h:
/usr/lib/gcc/arm-none-eabi/10.2.0/include/stdarg.h:
/usr/arm-none-eabi/include/sys/reent.h:
/usr/arm-none-eabi/include/_ansi.h:
/usr/arm-none-eabi/include/sys/_types.h:
/usr/arm-none-eabi/include/machine/_types.h:
/usr/arm-none-eabi/include/sys/lock.h:
/usr/arm-none-eabi/include/sys/types.h:
/usr/arm-none-eabi/include/sys/_stdint.h:
/usr/arm-none-eabi/include/machine/endian.h:
/usr/arm-none-eabi/include/machine/_endian.h:
/usr/arm-none-eabi/include/sys/select.h:
/usr/arm-none-eabi/include/sys/_sigset.h:
/usr/arm-none-eabi/include/sys/_timeval.h:
/usr/arm-none-eabi/include/sys/timespec.h:
/usr/arm-none-eabi/include/sys/_timespec.h:
/usr/arm-none-eabi/include/sys/_pthreadtypes.h:
/usr/arm-none-eabi/include/sys/sched.h:
/usr/arm-none-eabi/include/machine/types.h:
/usr/arm-none-eabi/include/sys/stdio.h:
/usr/arm-none-eabi/include/stdlib.h:
/usr/arm-none-eabi/include/machine/stdlib.h:
/usr/arm-none-eabi/include/alloca.h:
/usr/arm-none-eabi/include/string.h:
/usr/arm-none-eabi/include/sys/_locale.h:
/usr/arm-none-eabi/include/strings.h:
/usr/arm-none-eabi/include/sys/string.h:
../usb_start.h:
../usb/class/cdc/device/cdcdf_acm.h:
../usb/device/usbdc.h:
../usb/usb_includes.h:
/usr/lib/gcc/arm-none-eabi/10.2.0/include/stdbool.h:
/usr/lib/gcc/arm-none-eabi/10.2.0/include/stdint.h:
/usr/arm-none-eabi/include/stdint.h:
/usr/arm-none-eabi/include/sys/_intsup.h:
../hal/utils/include/utils.h:
../hal/utils/include/utils_list.h:
../hal/utils/include/compiler.h:
../hal/utils/include/parts.h:
../samd21a/include/samd21.h:
../samd21a/include/samd21e18a.h:
../CMSIS/Core/Include/core_cm0plus.h:
../CMSIS/Core/Include/cmsis_version.h:
../CMSIS/Core/Include/cmsis_compiler.h:
../CMSIS/Core/Include/cmsis_gcc.h:
../samd21a/include/system_samd21.h:
../samd21a/include/component/ac.h:
../samd21a/include/component/adc.h:
../samd21a/include/component/dac.h:
../samd21a/include/component/dmac.h:
../samd21a/include/component/dsu.h:
../samd21a/include/component/eic.h:
../samd21a/include/component/evsys.h:
../samd21a/include/component/gclk.h:
../samd21a/include/component/hmatrixb.h:
../samd21a/include/component/i2s.h:
../samd21a/include/component/mtb.h:
../samd21a/include/component/nvmctrl.h:
../samd21a/include/component/pac.h:
../samd21a/include/component/pm.h:
../samd21a/include/component/port.h:
../samd21a/include/component/rtc.h:
../samd21a/include/component/sercom.h:
../samd21a/include/component/sysctrl.h:
../samd21a/include/component/tc.h:
../samd21a/include/component/tcc.h:
../samd21a/include/component/usb.h:
../samd21a/include/component/wdt.h:
../samd21a/include/instance/ac.h:
../samd21a/include/instance/adc.h:
../samd21a/include/instance/dac.h:
../samd21a/include/instance/dmac.h:
../samd21a/include/instance/dsu.h:
../samd21a/include/instance/eic.h:
../samd21a/include/instance/evsys.h:
../samd21a/include/instance/gclk.h:
../samd21a/include/instance/sbmatrix.h:
../samd21a/include/instance/i2s.h:
../samd21a/include/instance/mtb.h:
../samd21a/include/instance/nvmctrl.h:
../samd21a/include/instance/pac0.h:
../samd21a/include/instance/pac1.h:
../samd21a/include/instance/pac2.h:
../samd21a/include/instance/pm.h:
../samd21a/include/instance/port.h:
../samd21a/include/instance/ptc.h:
../samd21a/include/instance/rtc.h:
../samd21a/include/instance/sercom0.h:
../samd21a/include/instance/sercom1.h:
../samd21a/include/instance/sercom2.h:
../samd21a/include/instance/sercom3.h:
../samd21a/include/instance/sysctrl.h:
../samd21a/include/instance/tc3.h:
../samd21a/include/instance/tc4.h:
../samd21a/include/instance/tc5.h:
../samd21a/include/instance/tcc0.h:
../samd21a/include/instance/tcc1.h:
../samd21a/include/instance/tcc2.h:
../samd21a/include/instance/usb.h:
../samd21a/include/instance/wdt.h:
../samd21a/include/pio/samd21e18a.h:
../hri/hri_d21.h:
../samd21a/include/sam.h:
../hri/hri_ac_d21.h:
../hal/include/hal_atomic.h:
../hri/hri_adc_d21.h:
../hri/hri_dac_d21.h:
../hri/hri_dmac_d21.h:
../hri/hri_dsu_d21.h:
../hri/hri_eic_d21.h:
../hri/hri_evsys_d21.h:
../hri/hri_gclk_d21.h:
../hri/hri_hmatrixb_d21.h:
../hri/hri_i2s_d21.h:
../hri/hri_mtb_d21.h:
../hri/hri_nvic_d21.h:
../hri/hri_nvmctrl_d21.h:
../hri/hri_pac_d21.h:
../hri/hri_pm_d21.h:
../hri/hri_port_d21.h:
../hri/hri_rtc_d21.h:
../hri/hri_sercom_d21.h:
../hri/hri_sysctrl_d21.h:
../hri/hri_systemcontrol_d21.h:
../hri/hri_systick_d21.h:
../hri/hri_tc_d21.h:
../hri/hri_tcc_d21.h:
../hri/hri_usb_d21.h:
../hri/hri_wdt_d21.h:
../hal/utils/include/err_codes.h:
../hal/utils/include/utils_assert.h:
../usb/usb_protocol.h:
../usb/usb_includes.h:
../hal/include/hal_usb_device.h:
../hal/include/hpl_usb_device.h:
../hal/include/hpl_usb.h:
../config/hpl_usb_config.h:
../config/usbd_config.h:
../usb/class/cdc/usb_protocol_cdc.h:
../usb/class/cdc/device/cdcdf_acm_desc.h:

Binary file not shown.

@ -1,17 +1,12 @@
#include <atmel_start.h> #include <atmel_start.h>
static uint8_t buffer[64]; #include "serial.h"
int main(void) int main(void)
{ {
/* Initializes MCU, drivers and middleware */ /* Initializes MCU, drivers and middleware */
atmel_start_init(); atmel_start_init();
arc_serial_init();
usb_init(); arc_printf("Hello World");
cdcd_acm_example();
while(!usb_ready());
delay_ms(2000);
memcpy(buffer, "Hello World\n", sizeof("Hello World\n"));
volatile int32_t ret = cdcdf_acm_write(buffer, sizeof("Hello World\n"));
/* Replace with your application code */ /* Replace with your application code */
while (1) { while (1) {
} }

@ -7,7 +7,6 @@
*/ */
#include "atmel_start.h" #include "atmel_start.h"
#include "usb_start.h" #include "usb_start.h"
static volatile bool b_usb_ready = false;
#if CONF_USBD_HS_SP #if CONF_USBD_HS_SP
static uint8_t single_desc_bytes[] = { static uint8_t single_desc_bytes[] = {
/* Device descriptors and Configuration descriptors list. */ /* Device descriptors and Configuration descriptors list. */
@ -65,7 +64,6 @@ static bool usb_device_cb_bulk_in(const uint8_t ep, const enum usb_xfer_code rc,
*/ */
static bool usb_device_cb_state_c(usb_cdc_control_signal_t state) static bool usb_device_cb_state_c(usb_cdc_control_signal_t state)
{ {
b_usb_ready = true;
/* if (state.rs232.DTR) { */ /* if (state.rs232.DTR) { */
/* /\* Callbacks must be registered after endpoint allocation *\/ */ /* /\* Callbacks must be registered after endpoint allocation *\/ */
/* cdcdf_acm_register_callback(CDCDF_ACM_CB_READ, (FUNC_PTR)usb_device_cb_bulk_out); */ /* cdcdf_acm_register_callback(CDCDF_ACM_CB_READ, (FUNC_PTR)usb_device_cb_bulk_out); */
@ -126,8 +124,3 @@ void usb_init(void)
cdc_device_acm_init(); cdc_device_acm_init();
} }
bool usb_ready()
{
return b_usb_ready;
}

@ -0,0 +1,42 @@
#include "serial.h"
#include "usb_start.h"
#define MAX_PRINTF_BUFFER (64)
static uint8_t printf_buffer[MAX_PRINTF_BUFFER];
static volatile bool b_usb_ready = false;
static bool usb_cb_state_c(usb_cdc_control_signal_t state)
{
if(state.rs232.DTR == 1)
{
b_usb_ready = true;
}
else
{
b_usb_ready = false;
}
return false;
}
void arc_serial_init()
{
memset(printf_buffer, '\0', MAX_PRINTF_BUFFER);
usb_init();
while(!cdcdf_acm_is_enabled()){}
cdcdf_acm_register_callback(CDCDF_ACM_CB_STATE_C, (FUNC_PTR)usb_cb_state_c);
while(!b_usb_ready);
delay_ms(2000);
}
uint8_t arc_printf(const char* fmt, ...)
{
while(!b_usb_ready){}
va_list args;
va_start(args, fmt);
vsprintf(printf_buffer, fmt, args);
va_end(args);
volatile int32_t ret = cdcdf_acm_write(printf_buffer, (uint32_t)(strlen((const char*)printf_buffer)));
return 0;
}

@ -0,0 +1,37 @@
#include "serial.h"
#include "usb_start.h"
#define MAX_PRINTF_BUFFER (64)
static uint32_t printf_buffer[MAX_PRINTF_BUFFER / 4];
static volatile bool b_usb_ready = false;
static bool usb_cb_state_c(usb_cdc_control_signal_t state)
{
if(state.rs232.DTR)
{
b_usb_ready = true;
}
return false;
}
void arc_serial_init()
{
memset(printf_buffer, '\0', MAX_PRINTF_BUFFER);
usb_init();
while(!cdcdf_acm_is_enabled()){}
cdcdf_acm_register_callback(CDCDF_ACM_CB_STATE_C, (FUNC_PTR)usb_cb_state_c);
while(!b_usb_ready){}
delay_ms(100);
}
uint8_t arc_printf(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
vsprintf((uint8_t*)printf_buffer, fmt, args);
va_end(args);
volatile int32_t ret = cdcdf_acm_write((uint8_t*)printf_buffer, strlen((const char*)printf_buffer));
return 0;
}

@ -0,0 +1,21 @@
#ifndef _SERIAL_H_
#define _SERIAL_H_
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
void arc_serial_init(void);
uint8_t arc_printf(const char* fmt, ...);
#ifdef DEBUG
#define printf(f_, ...) arc_printf((f_), ##__VA_ARGS__)
#else
#define printf(f_, ...) void(f_, ...)
#endif
#endif
Loading…
Cancel
Save