mirror of
https://github.com/eddyem/stm32samples.git
synced 2025-12-06 10:45:11 +03:00
F1-nolib/CDC_ACM/
This commit is contained in:
parent
df969849c5
commit
876eb82698
0
F0-nolib/Chiller/chiller.bin
Normal file → Executable file
0
F0-nolib/Chiller/chiller.bin
Normal file → Executable file
0
F0-nolib/F0_testbrd/pl2303.bin
Normal file → Executable file
0
F0-nolib/F0_testbrd/pl2303.bin
Normal file → Executable file
0
F0-nolib/QuadEncoder/encoder.bin
Normal file → Executable file
0
F0-nolib/QuadEncoder/encoder.bin
Normal file → Executable file
0
F0-nolib/Servo/servo.bin
Normal file → Executable file
0
F0-nolib/Servo/servo.bin
Normal file → Executable file
0
F0-nolib/TM1637/tm1637.bin
Normal file → Executable file
0
F0-nolib/TM1637/tm1637.bin
Normal file → Executable file
0
F0-nolib/USBHID/usbhid.bin
Normal file → Executable file
0
F0-nolib/USBHID/usbhid.bin
Normal file → Executable file
0
F0-nolib/blink/blink.bin
Normal file → Executable file
0
F0-nolib/blink/blink.bin
Normal file → Executable file
0
F0-nolib/canbus/src/canbus.bin
Normal file → Executable file
0
F0-nolib/canbus/src/canbus.bin
Normal file → Executable file
0
F0-nolib/htu21d_nucleo/usart.bin
Normal file → Executable file
0
F0-nolib/htu21d_nucleo/usart.bin
Normal file → Executable file
0
F0-nolib/morze/morze.bin
Normal file → Executable file
0
F0-nolib/morze/morze.bin
Normal file → Executable file
0
F0-nolib/pl2303/pl2303.bin
Normal file → Executable file
0
F0-nolib/pl2303/pl2303.bin
Normal file → Executable file
0
F0-nolib/tsys01_nucleo/tsys01.bin
Normal file → Executable file
0
F0-nolib/tsys01_nucleo/tsys01.bin
Normal file → Executable file
0
F0-nolib/uart_blink/uartblink.bin
Normal file → Executable file
0
F0-nolib/uart_blink/uartblink.bin
Normal file → Executable file
0
F0-nolib/uart_blink_dma/uartblink.bin
Normal file → Executable file
0
F0-nolib/uart_blink_dma/uartblink.bin
Normal file → Executable file
0
F0-nolib/uart_nucleo/usart.bin
Normal file → Executable file
0
F0-nolib/uart_nucleo/usart.bin
Normal file → Executable file
0
F0-nolib/usbcdc/usbcan.bin
Normal file → Executable file
0
F0-nolib/usbcdc/usbcan.bin
Normal file → Executable file
0
F0/blink/blink.bin
Normal file → Executable file
0
F0/blink/blink.bin
Normal file → Executable file
0
F0/uart/uart.bin
Normal file → Executable file
0
F0/uart/uart.bin
Normal file → Executable file
1
F1-nolib/CDC_ACM/CDCACM.cflags
Normal file
1
F1-nolib/CDC_ACM/CDCACM.cflags
Normal file
@ -0,0 +1 @@
|
|||||||
|
-std=c17
|
||||||
1
F1-nolib/CDC_ACM/CDCACM.cxxflags
Normal file
1
F1-nolib/CDC_ACM/CDCACM.cxxflags
Normal file
@ -0,0 +1 @@
|
|||||||
|
-std=c++17
|
||||||
139
F1-nolib/CDC_ACM/Makefile_old
Normal file
139
F1-nolib/CDC_ACM/Makefile_old
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
BINARY = cdcacm
|
||||||
|
BOOTPORT ?= /dev/ttyUSB0
|
||||||
|
BOOTSPEED ?= 115200
|
||||||
|
# MCU FAMILY
|
||||||
|
FAMILY ?= F1
|
||||||
|
# MCU code
|
||||||
|
MCU ?= F103x8
|
||||||
|
# density (stm32f10x.h, lines 70-84)
|
||||||
|
DENSITY ?= MD
|
||||||
|
# change this linking script depending on particular MCU model,
|
||||||
|
LDSCRIPT ?= stm32f103x8.ld
|
||||||
|
# debug
|
||||||
|
#DEFS = -DEBUG
|
||||||
|
|
||||||
|
INDEPENDENT_HEADERS=
|
||||||
|
|
||||||
|
FP_FLAGS ?= -msoft-float -mfloat-abi=soft
|
||||||
|
ASM_FLAGS ?= -mthumb -mcpu=cortex-m3 -mfix-cortex-m3-ldrd
|
||||||
|
ARCH_FLAGS = $(ASM_FLAGS) $(FP_FLAGS)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Executables
|
||||||
|
#PREFIX ?= arm-none-eabi
|
||||||
|
# gcc from arm web site
|
||||||
|
PREFIX ?= /opt/bin/arm-none-eabi
|
||||||
|
TOOLCHLIB ?= /opt/arm-none-eabi/lib
|
||||||
|
RM := rm -f
|
||||||
|
RMDIR := rmdir
|
||||||
|
CC := $(PREFIX)-gcc
|
||||||
|
# don't replace ld with gcc: the binary size would be much greater!!
|
||||||
|
LD := $(PREFIX)-ld
|
||||||
|
AR := $(PREFIX)-ar
|
||||||
|
AS := $(PREFIX)-as
|
||||||
|
SIZE := $(PREFIX)-size
|
||||||
|
OBJCOPY := $(PREFIX)-objcopy
|
||||||
|
OBJDUMP := $(PREFIX)-objdump
|
||||||
|
GDB := $(PREFIX)-gdb
|
||||||
|
STFLASH := $(shell which st-flash)
|
||||||
|
STBOOT := $(shell which stm32flash)
|
||||||
|
DFUUTIL := $(shell which dfu-util)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Source files
|
||||||
|
OBJDIR = mk
|
||||||
|
SRC := $(wildcard *.c)
|
||||||
|
OBJS := $(addprefix $(OBJDIR)/, $(SRC:%.c=%.o))
|
||||||
|
STARTUP = $(OBJDIR)/startup.o
|
||||||
|
OBJS += $(STARTUP)
|
||||||
|
# dependencies: we need them to recompile files if their headers-dependencies changed
|
||||||
|
DEPS := $(OBJS:.o=.d)
|
||||||
|
|
||||||
|
INC_DIR ?= ../inc
|
||||||
|
|
||||||
|
INCLUDE := -I$(INC_DIR)/Fx -I$(INC_DIR)/cm
|
||||||
|
LIB_DIR := $(INC_DIR)/ld
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# C flags
|
||||||
|
CFLAGS += -O2 -g -D__thumb2__=1 -MD
|
||||||
|
CFLAGS += -Wall -Werror -Wextra -Wshadow
|
||||||
|
CFLAGS += -fno-common -ffunction-sections -fdata-sections -fno-stack-protector
|
||||||
|
CFLAGS += $(ARCH_FLAGS)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Linker flags
|
||||||
|
LDFLAGS += -nostartfiles --static -nostdlibs
|
||||||
|
LDFLAGS += -L$(LIB_DIR) -L$(TOOLCHLIB)
|
||||||
|
LDFLAGS += -T$(LDSCRIPT)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Used libraries
|
||||||
|
LDLIBS += -lc $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
||||||
|
|
||||||
|
PLATFRM ?= -DSTM32$(FAMILY) -DSTM32$(MCU) -DSTM32F10X_$(DENSITY)
|
||||||
|
|
||||||
|
ELF := $(OBJDIR)/$(BINARY).elf
|
||||||
|
LIST := $(OBJDIR)/$(BINARY).list
|
||||||
|
BIN := $(BINARY).bin
|
||||||
|
HEX := $(BINARY).hex
|
||||||
|
|
||||||
|
all: bin list size
|
||||||
|
|
||||||
|
elf: $(ELF)
|
||||||
|
bin: $(BIN)
|
||||||
|
hex: $(HEX)
|
||||||
|
list: $(LIST)
|
||||||
|
|
||||||
|
ifneq ($(MAKECMDGOALS),clean)
|
||||||
|
-include $(DEPS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir $(OBJDIR)
|
||||||
|
|
||||||
|
$(STARTUP): $(INC_DIR)/startup/vector.c
|
||||||
|
$(CC) $(CFLAGS) $(DEFS) $(PLATFRM) $(INCLUDE) -o $@ -c $<
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.c
|
||||||
|
@echo " CC $<"
|
||||||
|
$(CC) $(CFLAGS) $(DEFS) $(PLATFRM) $(INCLUDE) -o $@ -c $<
|
||||||
|
|
||||||
|
$(BIN): $(ELF)
|
||||||
|
@echo " OBJCOPY $(BIN)"
|
||||||
|
$(OBJCOPY) -Obinary $(ELF) $(BIN)
|
||||||
|
|
||||||
|
$(HEX): $(ELF)
|
||||||
|
@echo " OBJCOPY $(HEX)"
|
||||||
|
$(OBJCOPY) -Oihex $(ELF) $(HEX)
|
||||||
|
|
||||||
|
$(LIST): $(ELF)
|
||||||
|
@echo " OBJDUMP $(LIST)"
|
||||||
|
$(OBJDUMP) -S $(ELF) > $(LIST)
|
||||||
|
|
||||||
|
$(ELF): $(OBJDIR) $(OBJS)
|
||||||
|
@echo " LD $(ELF)"
|
||||||
|
$(LD) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $(ELF)
|
||||||
|
|
||||||
|
size: $(ELF)
|
||||||
|
$(SIZE) $(ELF)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo " CLEAN"
|
||||||
|
$(RM) $(OBJS) $(DEPS) $(ELF) $(HEX) $(LIST)
|
||||||
|
@rmdir $(OBJDIR) 2>/dev/null || true
|
||||||
|
|
||||||
|
|
||||||
|
flash: $(BIN)
|
||||||
|
@echo " FLASH $(BIN)"
|
||||||
|
$(STFLASH) write $(BIN) 0x8000000
|
||||||
|
|
||||||
|
boot: $(BIN)
|
||||||
|
@echo " LOAD $(BIN) through bootloader"
|
||||||
|
$(STBOOT) -b$(BOOTSPEED) $(BOOTPORT) -w $(BIN)
|
||||||
|
|
||||||
|
dfuboot: $(BIN)
|
||||||
|
@echo " LOAD $(BIN) THROUGH DFU"
|
||||||
|
$(DFUUTIL) -a0 -D $(BIN) -s 0x08000000
|
||||||
|
|
||||||
|
.PHONY: clean flash boot
|
||||||
BIN
F1-nolib/CDC_ACM/cdcacm.bin
Normal file → Executable file
BIN
F1-nolib/CDC_ACM/cdcacm.bin
Normal file → Executable file
Binary file not shown.
@ -102,6 +102,7 @@ char *get_USB(){
|
|||||||
int x = USB_receive(curptr, rest);
|
int x = USB_receive(curptr, rest);
|
||||||
curptr[x] = 0;
|
curptr[x] = 0;
|
||||||
if(!x) return NULL;
|
if(!x) return NULL;
|
||||||
|
MSG(tmpbuf);
|
||||||
if(curptr[x-1] == '\n'){
|
if(curptr[x-1] == '\n'){
|
||||||
curptr = tmpbuf;
|
curptr = tmpbuf;
|
||||||
rest = 511;
|
rest = 511;
|
||||||
@ -145,7 +146,7 @@ char *u2str(uint32_t val){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(void){
|
int main(void){
|
||||||
uint32_t lastT = 0, Tp = 499;
|
uint32_t lastT = 0;
|
||||||
sysreset();
|
sysreset();
|
||||||
StartHSE();
|
StartHSE();
|
||||||
SysTick_Config(72000);
|
SysTick_Config(72000);
|
||||||
@ -162,26 +163,25 @@ int main(void){
|
|||||||
RCC->CSR |= RCC_CSR_RMVF; // remove reset flags
|
RCC->CSR |= RCC_CSR_RMVF; // remove reset flags
|
||||||
|
|
||||||
USB_setup();
|
USB_setup();
|
||||||
iwdg_setup();
|
//iwdg_setup();
|
||||||
USBPU_ON();
|
USBPU_ON();
|
||||||
|
|
||||||
uint32_t ctr = 0;
|
//uint32_t ctr = 0;
|
||||||
while (1){
|
while (1){
|
||||||
IWDG->KR = IWDG_REFRESH; // refresh watchdog
|
IWDG->KR = IWDG_REFRESH; // refresh watchdog
|
||||||
if(lastT > Tms || Tms - lastT > Tp){
|
if(Tms - lastT > 499){
|
||||||
LED_blink(LED0);
|
LED_blink(LED0);
|
||||||
lastT = Tms;
|
lastT = Tms;
|
||||||
|
transmit_tbuf();
|
||||||
|
/*
|
||||||
if(usbON){
|
if(usbON){
|
||||||
USB_send("String #");
|
USB_send("String #");
|
||||||
char *s = u2str(ctr++);
|
char *s = u2str(ctr++);
|
||||||
//SEND(s); SEND("th string"); newline();
|
|
||||||
USB_send(s);
|
USB_send(s);
|
||||||
USB_send("\n");
|
USB_send("\n");
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
usb_proc();
|
usb_proc();
|
||||||
if(usbON) Tp = 999;
|
|
||||||
else Tp = 499;
|
|
||||||
char *txt, *ans;
|
char *txt, *ans;
|
||||||
if((txt = get_USB())){
|
if((txt = get_USB())){
|
||||||
ans = parse_cmd(txt);
|
ans = parse_cmd(txt);
|
||||||
|
|||||||
93
F1-nolib/CDC_ACM/sync.c
Normal file
93
F1-nolib/CDC_ACM/sync.c
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Fergus Noble <fergusnoble@gmail.com>
|
||||||
|
*
|
||||||
|
* This library is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO:
|
||||||
|
* implement mutexes for other type of MCU (which doesn't have strex & ldrex)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sync.h"
|
||||||
|
|
||||||
|
/* DMB is supported on CM0 */
|
||||||
|
void __dmb()
|
||||||
|
{
|
||||||
|
__asm__ volatile ("dmb");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Those are defined only on CM3 or CM4 */
|
||||||
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
||||||
|
|
||||||
|
uint32_t __ldrex(volatile uint32_t *addr)
|
||||||
|
{
|
||||||
|
uint32_t res;
|
||||||
|
__asm__ volatile ("ldrex %0, [%1]" : "=r" (res) : "r" (addr));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t __strex(uint32_t val, volatile uint32_t *addr)
|
||||||
|
{
|
||||||
|
uint32_t res;
|
||||||
|
__asm__ volatile ("strex %0, %2, [%1]"
|
||||||
|
: "=&r" (res) : "r" (addr), "r" (val));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mutex_lock(mutex_t *m)
|
||||||
|
{
|
||||||
|
uint32_t status = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
/* Wait until the mutex is unlocked. */
|
||||||
|
while (__ldrex(m) != MUTEX_UNLOCKED);
|
||||||
|
|
||||||
|
/* Try to acquire it. */
|
||||||
|
status = __strex(MUTEX_LOCKED, m);
|
||||||
|
|
||||||
|
/* Did we get it? If not then try again. */
|
||||||
|
} while (status != 0);
|
||||||
|
|
||||||
|
/* Execute the mysterious Data Memory Barrier instruction! */
|
||||||
|
__dmb();
|
||||||
|
}
|
||||||
|
|
||||||
|
void mutex_unlock(mutex_t *m)
|
||||||
|
{
|
||||||
|
/* Ensure accesses to protected resource are finished */
|
||||||
|
__dmb();
|
||||||
|
|
||||||
|
/* Free the lock. */
|
||||||
|
*m = MUTEX_UNLOCKED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to lock mutex
|
||||||
|
* if it's already locked or there was error in STREX, return MUTEX_LOCKED
|
||||||
|
* else return MUTEX_UNLOCKED
|
||||||
|
*/
|
||||||
|
mutex_t mutex_trylock(mutex_t *m){
|
||||||
|
uint32_t status = 0;
|
||||||
|
mutex_t old_lock = __ldrex(m); // get mutex value
|
||||||
|
// set mutex
|
||||||
|
status = __strex(MUTEX_LOCKED, m);
|
||||||
|
if(status == 0) __dmb();
|
||||||
|
else old_lock = MUTEX_LOCKED;
|
||||||
|
return old_lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
57
F1-nolib/CDC_ACM/sync.h
Normal file
57
F1-nolib/CDC_ACM/sync.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Fergus Noble <fergusnoble@gmail.com>
|
||||||
|
*
|
||||||
|
* This library is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#ifndef SYNC_H__
|
||||||
|
#define SYNC_H__
|
||||||
|
|
||||||
|
#include "stm32f1.h"
|
||||||
|
void __dmb(void);
|
||||||
|
|
||||||
|
/* Implements synchronisation primitives as discussed in the ARM document
|
||||||
|
* DHT0008A (ID081709) "ARM Synchronization Primitives" and the ARM v7-M
|
||||||
|
* Architecture Reference Manual.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* --- Exclusive load and store instructions ------------------------------- */
|
||||||
|
|
||||||
|
/* Those are defined only on CM3 or CM4 */
|
||||||
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
||||||
|
|
||||||
|
uint32_t __ldrex(volatile uint32_t *addr);
|
||||||
|
uint32_t __strex(uint32_t val, volatile uint32_t *addr);
|
||||||
|
|
||||||
|
/* --- Convenience functions ----------------------------------------------- */
|
||||||
|
|
||||||
|
/* Here we implement some simple synchronisation primitives. */
|
||||||
|
|
||||||
|
typedef uint32_t mutex_t;
|
||||||
|
|
||||||
|
#define MUTEX_UNLOCKED 0
|
||||||
|
#define MUTEX_LOCKED 1
|
||||||
|
|
||||||
|
void mutex_lock(mutex_t *m);
|
||||||
|
void mutex_unlock(mutex_t *m);
|
||||||
|
mutex_t mutex_trylock(mutex_t *m);
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "This arch have NO ldrex/strex!"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // SYNC_H__
|
||||||
@ -19,20 +19,23 @@
|
|||||||
* MA 02110-1301, USA.
|
* MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
#include "stm32f1.h"
|
#include "stm32f1.h"
|
||||||
|
#include "sync.h"
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
|
|
||||||
extern volatile uint32_t Tms;
|
extern volatile uint32_t Tms;
|
||||||
static volatile int idatalen[2] = {0,0}; // received data line length (including '\n')
|
static volatile int idatalen[2] = {0,0}; // received data line length (including '\n')
|
||||||
static volatile int odatalen[2] = {0,0};
|
static volatile int odatalen[2] = {0,0};
|
||||||
|
|
||||||
volatile int linerdy = 0, // received data ready
|
static int dlen = 0; // length of data (including '\n') in current buffer
|
||||||
dlen = 0, // length of data (including '\n') in current buffer
|
|
||||||
|
int linerdy = 0, // received data ready
|
||||||
bufovr = 0, // input buffer overfull
|
bufovr = 0, // input buffer overfull
|
||||||
txrdy = 1 // transmission done
|
txrdy = 1 // transmission done
|
||||||
;
|
;
|
||||||
|
|
||||||
|
static mutex_t the_mutex = MUTEX_UNLOCKED; // mutex for sending messages
|
||||||
|
|
||||||
int rbufno = 0, tbufno = 0; // current rbuf/tbuf numbers
|
static int rbufno = 0, tbufno = 0; // current rbuf/tbuf numbers
|
||||||
static char rbuf[2][UARTBUFSZI], tbuf[2][UARTBUFSZO]; // receive & transmit buffers
|
static char rbuf[2][UARTBUFSZI], tbuf[2][UARTBUFSZO]; // receive & transmit buffers
|
||||||
static char *recvdata = NULL;
|
static char *recvdata = NULL;
|
||||||
|
|
||||||
@ -52,13 +55,20 @@ int usart_getline(char **line){
|
|||||||
|
|
||||||
// transmit current tbuf and swap buffers
|
// transmit current tbuf and swap buffers
|
||||||
void transmit_tbuf(){
|
void transmit_tbuf(){
|
||||||
uint32_t tmout = 16000000;
|
uint32_t tmout = 160000;
|
||||||
|
mutex_lock(&the_mutex);
|
||||||
while(!txrdy){ // wait for previos buffer transmission
|
while(!txrdy){ // wait for previos buffer transmission
|
||||||
IWDG->KR = IWDG_REFRESH;
|
IWDG->KR = IWDG_REFRESH;
|
||||||
if(--tmout == 0) return;
|
if(--tmout == 0){
|
||||||
|
mutex_unlock(&the_mutex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
register int l = odatalen[tbufno];
|
register int l = odatalen[tbufno];
|
||||||
if(!l) return;
|
if(!l){
|
||||||
|
mutex_unlock(&the_mutex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
txrdy = 0;
|
txrdy = 0;
|
||||||
odatalen[tbufno] = 0;
|
odatalen[tbufno] = 0;
|
||||||
DMA1_Channel4->CCR &= ~DMA_CCR_EN;
|
DMA1_Channel4->CCR &= ~DMA_CCR_EN;
|
||||||
@ -66,24 +76,39 @@ void transmit_tbuf(){
|
|||||||
DMA1_Channel4->CNDTR = l;
|
DMA1_Channel4->CNDTR = l;
|
||||||
DMA1_Channel4->CCR |= DMA_CCR_EN;
|
DMA1_Channel4->CCR |= DMA_CCR_EN;
|
||||||
tbufno = !tbufno;
|
tbufno = !tbufno;
|
||||||
|
mutex_unlock(&the_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void usart_putchar(const char ch){
|
void usart_putchar(const char ch){
|
||||||
if(odatalen[tbufno] == UARTBUFSZO) transmit_tbuf();
|
mutex_lock(&the_mutex);
|
||||||
|
if(odatalen[tbufno] == UARTBUFSZO){
|
||||||
|
mutex_unlock(&the_mutex);
|
||||||
|
//return;
|
||||||
|
transmit_tbuf();
|
||||||
|
mutex_lock(&the_mutex);
|
||||||
|
}
|
||||||
tbuf[tbufno][odatalen[tbufno]++] = ch;
|
tbuf[tbufno][odatalen[tbufno]++] = ch;
|
||||||
|
mutex_unlock(&the_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void usart_send(const char *str){
|
void usart_send(const char *str){
|
||||||
uint32_t x = 512;
|
uint32_t x = 512;
|
||||||
|
mutex_lock(&the_mutex);
|
||||||
while(*str && --x){
|
while(*str && --x){
|
||||||
if(odatalen[tbufno] == UARTBUFSZO) transmit_tbuf();
|
if(odatalen[tbufno] == UARTBUFSZO){
|
||||||
|
mutex_unlock(&the_mutex);
|
||||||
|
//return;
|
||||||
|
transmit_tbuf();
|
||||||
|
mutex_lock(&the_mutex);
|
||||||
|
}
|
||||||
tbuf[tbufno][odatalen[tbufno]++] = *str++;
|
tbuf[tbufno][odatalen[tbufno]++] = *str++;
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&the_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void newline(){
|
void newline(){
|
||||||
usart_putchar('\n');
|
usart_putchar('\n');
|
||||||
transmit_tbuf();
|
//transmit_tbuf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -110,7 +135,8 @@ void usart_setup(){
|
|||||||
NVIC_EnableIRQ(DMA1_Channel4_IRQn);
|
NVIC_EnableIRQ(DMA1_Channel4_IRQn);
|
||||||
NVIC_SetPriority(USART1_IRQn, 0);
|
NVIC_SetPriority(USART1_IRQn, 0);
|
||||||
// setup usart1
|
// setup usart1
|
||||||
USART1->BRR = 72000000 / 115200;
|
//USART1->BRR = 72000000 / 115200;
|
||||||
|
USART1->BRR = 24; // 3000000
|
||||||
USART1->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_UE; // 1start,8data,nstop; enable Rx,Tx,USART
|
USART1->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_UE; // 1start,8data,nstop; enable Rx,Tx,USART
|
||||||
while(!(USART1->SR & USART_SR_TC)){ // polling idle frame Transmission
|
while(!(USART1->SR & USART_SR_TC)){ // polling idle frame Transmission
|
||||||
IWDG->KR = IWDG_REFRESH;
|
IWDG->KR = IWDG_REFRESH;
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
// input and output buffers size
|
// input and output buffers size
|
||||||
#define UARTBUFSZI (16)
|
#define UARTBUFSZI (16)
|
||||||
#define UARTBUFSZO (32)
|
#define UARTBUFSZO (512)
|
||||||
// timeout between data bytes
|
// timeout between data bytes
|
||||||
#ifndef TIMEOUT_MS
|
#ifndef TIMEOUT_MS
|
||||||
#define TIMEOUT_MS (1500)
|
#define TIMEOUT_MS (1500)
|
||||||
@ -33,19 +33,23 @@
|
|||||||
|
|
||||||
// macro for static strings
|
// macro for static strings
|
||||||
#define SEND(str) usart_send(str)
|
#define SEND(str) usart_send(str)
|
||||||
|
#define _s(s) #s
|
||||||
|
#define STR(s) _s(s)
|
||||||
|
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
#define DBG(str) do{SEND(__func__); SEND(": " str); newline();}while(0)
|
#define DBG(str) do{SEND(__FILE__ " (L" STR(__LINE__) "): " str); newline();}while(0)
|
||||||
#define MSG(str) do{SEND(str); newline();}while(0)
|
#define HERE() do{SEND(STR(__LINE__)); usart_putchar('\n');}while(0)
|
||||||
|
#define MSG(str) do{SEND(str); usart_putchar('\n');}while(0)
|
||||||
#else
|
#else
|
||||||
#define MSG(str)
|
#define MSG(str)
|
||||||
|
#define HERE()
|
||||||
#define DBG(str)
|
#define DBG(str)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define usartrx() (linerdy)
|
#define usartrx() (linerdy)
|
||||||
#define usartovr() (bufovr)
|
#define usartovr() (bufovr)
|
||||||
|
|
||||||
extern volatile int linerdy, bufovr, txrdy;
|
extern int linerdy, bufovr, txrdy;
|
||||||
|
|
||||||
void transmit_tbuf();
|
void transmit_tbuf();
|
||||||
void usart_setup();
|
void usart_setup();
|
||||||
|
|||||||
@ -105,7 +105,6 @@ void USB_send(const char *buf){
|
|||||||
if(!usbON) return; // USB disconnected
|
if(!usbON) return; // USB disconnected
|
||||||
uint16_t l = 0, ctr = 0;
|
uint16_t l = 0, ctr = 0;
|
||||||
const char *p = buf;
|
const char *p = buf;
|
||||||
//SEND("buf: "); SEND(buf); newline();
|
|
||||||
while(*p++) ++l;
|
while(*p++) ++l;
|
||||||
while(l){
|
while(l){
|
||||||
uint16_t s = (l > USB_TXBUFSZ) ? USB_TXBUFSZ : l;
|
uint16_t s = (l > USB_TXBUFSZ) ? USB_TXBUFSZ : l;
|
||||||
|
|||||||
@ -29,10 +29,9 @@ ep_t endpoints[STM32ENDPOINTS];
|
|||||||
|
|
||||||
usb_dev_t USB_Dev;
|
usb_dev_t USB_Dev;
|
||||||
static usb_LineCoding lineCoding = {115200, 0, 0, 8};
|
static usb_LineCoding lineCoding = {115200, 0, 0, 8};
|
||||||
config_pack_t setup_packet;
|
static config_pack_t setup_packet;
|
||||||
static uint8_t ep0databuf[EP0DATABUF_SIZE];
|
static uint8_t ep0databuf[EP0DATABUF_SIZE];
|
||||||
static uint8_t ep0dbuflen = 0;
|
static uint8_t ep0dbuflen = 0;
|
||||||
uint8_t USB_connected = 0;
|
|
||||||
|
|
||||||
usb_LineCoding getLineCoding(){return lineCoding;}
|
usb_LineCoding getLineCoding(){return lineCoding;}
|
||||||
|
|
||||||
@ -64,7 +63,7 @@ static const uint8_t USB_DeviceDescriptor[] = {
|
|||||||
0x24, // idProduct_H
|
0x24, // idProduct_H
|
||||||
*/
|
*/
|
||||||
0x00, // bcdDevice_Ver_L
|
0x00, // bcdDevice_Ver_L
|
||||||
0x01, // bcdDevice_Ver_H
|
0x02, // bcdDevice_Ver_H
|
||||||
0x01, // iManufacturer
|
0x01, // iManufacturer
|
||||||
0x02, // iProduct
|
0x02, // iProduct
|
||||||
0x03, // iSerialNumber
|
0x03, // iSerialNumber
|
||||||
@ -178,11 +177,11 @@ static const uint8_t USB_ConfigDescriptor[] = {
|
|||||||
|
|
||||||
|
|
||||||
USB_LANG_ID(USB_StringLangDescriptor, LANG_US);
|
USB_LANG_ID(USB_StringLangDescriptor, LANG_US);
|
||||||
|
|
||||||
USB_STRING(USB_StringSerialDescriptor, u"000001");
|
USB_STRING(USB_StringSerialDescriptor, u"000001");
|
||||||
USB_STRING(USB_StringManufacturingDescriptor, u"Eddy @ SAO RAS");
|
USB_STRING(USB_StringManufacturingDescriptor, u"Eddy @ SAO RAS");
|
||||||
USB_STRING(USB_StringProdDescriptor, u"USB-Serial Controller");
|
USB_STRING(USB_StringProdDescriptor, u"USB-Serial Controller");
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* default handlers
|
* default handlers
|
||||||
*/
|
*/
|
||||||
@ -216,7 +215,6 @@ static uint16_t wr0(const uint8_t *buf, uint16_t size, uint16_t status){
|
|||||||
uint8_t needzlp = (l == endpoints[0].txbufsz) ? 1 : 0;
|
uint8_t needzlp = (l == endpoints[0].txbufsz) ? 1 : 0;
|
||||||
if(size || needzlp){ // send last data buffer
|
if(size || needzlp){ // send last data buffer
|
||||||
USB->ISTR = 0;
|
USB->ISTR = 0;
|
||||||
//status = SET_NAK_RX(status);
|
|
||||||
status = SET_VALID_TX(status);
|
status = SET_VALID_TX(status);
|
||||||
status = KEEP_DTOG_TX(status);
|
status = KEEP_DTOG_TX(status);
|
||||||
status = KEEP_DTOG_RX(status);
|
status = KEEP_DTOG_RX(status);
|
||||||
@ -239,24 +237,31 @@ static uint16_t wr0(const uint8_t *buf, uint16_t size, uint16_t status){
|
|||||||
static inline uint16_t get_descriptor(uint16_t status){
|
static inline uint16_t get_descriptor(uint16_t status){
|
||||||
switch(setup_packet.wValue){
|
switch(setup_packet.wValue){
|
||||||
case DEVICE_DESCRIPTOR:
|
case DEVICE_DESCRIPTOR:
|
||||||
|
MSG("DEVICE_D");
|
||||||
status = wr0(USB_DeviceDescriptor, sizeof(USB_DeviceDescriptor), status);
|
status = wr0(USB_DeviceDescriptor, sizeof(USB_DeviceDescriptor), status);
|
||||||
break;
|
break;
|
||||||
case CONFIGURATION_DESCRIPTOR:
|
case CONFIGURATION_DESCRIPTOR:
|
||||||
|
MSG("CONF_D");
|
||||||
status = wr0(USB_ConfigDescriptor, sizeof(USB_ConfigDescriptor), status);
|
status = wr0(USB_ConfigDescriptor, sizeof(USB_ConfigDescriptor), status);
|
||||||
break;
|
break;
|
||||||
case STRING_LANG_DESCRIPTOR:
|
case STRING_LANG_DESCRIPTOR:
|
||||||
|
MSG("S_L_D");
|
||||||
status = wr0((const uint8_t *)&USB_StringLangDescriptor, STRING_LANG_DESCRIPTOR_SIZE_BYTE, status);
|
status = wr0((const uint8_t *)&USB_StringLangDescriptor, STRING_LANG_DESCRIPTOR_SIZE_BYTE, status);
|
||||||
break;
|
break;
|
||||||
case STRING_MAN_DESCRIPTOR:
|
case STRING_MAN_DESCRIPTOR:
|
||||||
|
MSG("S_M_D");
|
||||||
status = wr0((const uint8_t *)&USB_StringManufacturingDescriptor, USB_StringManufacturingDescriptor.bLength, status);
|
status = wr0((const uint8_t *)&USB_StringManufacturingDescriptor, USB_StringManufacturingDescriptor.bLength, status);
|
||||||
break;
|
break;
|
||||||
case STRING_PROD_DESCRIPTOR:
|
case STRING_PROD_DESCRIPTOR:
|
||||||
|
MSG("S_P_D");
|
||||||
status = wr0((const uint8_t *)&USB_StringProdDescriptor, USB_StringProdDescriptor.bLength, status);
|
status = wr0((const uint8_t *)&USB_StringProdDescriptor, USB_StringProdDescriptor.bLength, status);
|
||||||
break;
|
break;
|
||||||
case STRING_SN_DESCRIPTOR:
|
case STRING_SN_DESCRIPTOR:
|
||||||
|
MSG("S_SN_D");
|
||||||
status = wr0((const uint8_t *)&USB_StringSerialDescriptor, USB_StringSerialDescriptor.bLength, status);
|
status = wr0((const uint8_t *)&USB_StringSerialDescriptor, USB_StringSerialDescriptor.bLength, status);
|
||||||
break;
|
break;
|
||||||
case DEVICE_QUALIFIER_DESCRIPTOR:
|
case DEVICE_QUALIFIER_DESCRIPTOR:
|
||||||
|
MSG("D_Q_D");
|
||||||
status = wr0(USB_DeviceQualifierDescriptor, USB_DeviceQualifierDescriptor[0], status);
|
status = wr0(USB_DeviceQualifierDescriptor, USB_DeviceQualifierDescriptor[0], status);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -274,9 +279,11 @@ static inline uint16_t std_d2h_req(uint16_t status){
|
|||||||
status = get_descriptor(status);
|
status = get_descriptor(status);
|
||||||
break;
|
break;
|
||||||
case GET_STATUS:
|
case GET_STATUS:
|
||||||
|
MSG("GET_STAT");
|
||||||
EP_WriteIRQ(0, (uint8_t *)&state, 2); // send status: Bus Powered
|
EP_WriteIRQ(0, (uint8_t *)&state, 2); // send status: Bus Powered
|
||||||
break;
|
break;
|
||||||
case GET_CONFIGURATION:
|
case GET_CONFIGURATION:
|
||||||
|
MSG("GET_CONF");
|
||||||
EP_WriteIRQ(0, &configuration, 1);
|
EP_WriteIRQ(0, &configuration, 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -289,10 +296,12 @@ static inline uint16_t std_d2h_req(uint16_t status){
|
|||||||
static inline void std_h2d_req(){
|
static inline void std_h2d_req(){
|
||||||
switch(setup_packet.bRequest){
|
switch(setup_packet.bRequest){
|
||||||
case SET_ADDRESS:
|
case SET_ADDRESS:
|
||||||
|
MSG("SET_ADDR");
|
||||||
// new address will be assigned later - after acknowlegement or request to host
|
// new address will be assigned later - after acknowlegement or request to host
|
||||||
USB_Dev.USB_Addr = setup_packet.wValue;
|
USB_Dev.USB_Addr = setup_packet.wValue;
|
||||||
break;
|
break;
|
||||||
case SET_CONFIGURATION:
|
case SET_CONFIGURATION:
|
||||||
|
MSG("SET_CONF");
|
||||||
// Now device configured
|
// Now device configured
|
||||||
USB_Dev.USB_Status = USB_STATE_CONFIGURED;
|
USB_Dev.USB_Status = USB_STATE_CONFIGURED;
|
||||||
configuration = setup_packet.wValue;
|
configuration = setup_packet.wValue;
|
||||||
@ -327,29 +336,34 @@ static uint16_t EP0_Handler(ep_t ep){
|
|||||||
std_h2d_req();
|
std_h2d_req();
|
||||||
EP_WriteIRQ(0, (uint8_t *)0, 0);
|
EP_WriteIRQ(0, (uint8_t *)0, 0);
|
||||||
}
|
}
|
||||||
//epstatus = SET_NAK_RX(epstatus);
|
// epstatus = SET_VALID_TX(epstatus);
|
||||||
epstatus = SET_VALID_TX(epstatus);
|
|
||||||
break;
|
break;
|
||||||
case STANDARD_ENDPOINT_REQUEST_TYPE: // standard endpoint request
|
case STANDARD_ENDPOINT_REQUEST_TYPE: // standard endpoint request
|
||||||
if(setup_packet.bRequest == CLEAR_FEATURE){
|
if(setup_packet.bRequest == CLEAR_FEATURE){
|
||||||
|
MSG("CLEAR_F");
|
||||||
EP_WriteIRQ(0, (uint8_t *)0, 0);
|
EP_WriteIRQ(0, (uint8_t *)0, 0);
|
||||||
//epstatus = SET_NAK_RX(epstatus);
|
// epstatus = SET_VALID_TX(epstatus);
|
||||||
epstatus = SET_VALID_TX(epstatus);
|
}else{
|
||||||
|
DBG("WTF?");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONTROL_REQUEST_TYPE:
|
case CONTROL_REQUEST_TYPE:
|
||||||
switch(setup_packet.bRequest){
|
switch(setup_packet.bRequest){
|
||||||
case GET_LINE_CODING:
|
case GET_LINE_CODING:
|
||||||
|
MSG("GET_LINE_C");
|
||||||
EP_WriteIRQ(0, (uint8_t*)&lineCoding, sizeof(lineCoding));
|
EP_WriteIRQ(0, (uint8_t*)&lineCoding, sizeof(lineCoding));
|
||||||
break;
|
break;
|
||||||
case SET_LINE_CODING: // omit this for next stage, when data will come
|
case SET_LINE_CODING: // omit this for next stage, when data will come
|
||||||
|
MSG("SET_LINE_C");
|
||||||
usbON = 1;
|
usbON = 1;
|
||||||
break;
|
break;
|
||||||
case SET_CONTROL_LINE_STATE:
|
case SET_CONTROL_LINE_STATE:
|
||||||
|
MSG("SET_CLS");
|
||||||
usbON = 1;
|
usbON = 1;
|
||||||
clstate_handler(setup_packet.wValue);
|
clstate_handler(setup_packet.wValue);
|
||||||
break;
|
break;
|
||||||
case SEND_BREAK:
|
case SEND_BREAK:
|
||||||
|
MSG("SEND_BREAK");
|
||||||
usbON = 0;
|
usbON = 0;
|
||||||
break_handler();
|
break_handler();
|
||||||
break;
|
break;
|
||||||
@ -357,16 +371,15 @@ static uint16_t EP0_Handler(ep_t ep){
|
|||||||
DBG("WTF?");
|
DBG("WTF?");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//if(!dev2host) EP_WriteIRQ(0, (uint8_t *)0, 0); // write acknowledgement
|
|
||||||
if(setup_packet.bRequest != GET_LINE_CODING) EP_WriteIRQ(0, (uint8_t *)0, 0);
|
if(setup_packet.bRequest != GET_LINE_CODING) EP_WriteIRQ(0, (uint8_t *)0, 0);
|
||||||
epstatus = SET_VALID_RX(epstatus);
|
// epstatus = SET_VALID_RX(epstatus);
|
||||||
epstatus = SET_VALID_TX(epstatus);
|
// epstatus = SET_VALID_TX(epstatus);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
EP_WriteIRQ(0, (uint8_t *)0, 0);
|
EP_WriteIRQ(0, (uint8_t *)0, 0);
|
||||||
DBG("WTF?");
|
DBG("WTF?");
|
||||||
epstatus = SET_NAK_RX(epstatus);
|
// epstatus = SET_NAK_RX(epstatus);
|
||||||
epstatus = SET_VALID_TX(epstatus);
|
// epstatus = SET_VALID_TX(epstatus);
|
||||||
}
|
}
|
||||||
}else if (ep.rx_flag){ // got data over EP0 or host acknowlegement
|
}else if (ep.rx_flag){ // got data over EP0 or host acknowlegement
|
||||||
if(ep.rx_cnt){
|
if(ep.rx_cnt){
|
||||||
@ -374,25 +387,23 @@ static uint16_t EP0_Handler(ep_t ep){
|
|||||||
linecoding_handler((usb_LineCoding*)ep0databuf);
|
linecoding_handler((usb_LineCoding*)ep0databuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Close transaction
|
|
||||||
//epstatus = CLEAR_DTOG_RX(epstatus);
|
|
||||||
//epstatus = CLEAR_DTOG_TX(epstatus);
|
|
||||||
// wait for new data from host
|
// wait for new data from host
|
||||||
epstatus = SET_VALID_RX(epstatus);
|
// epstatus = SET_VALID_RX(epstatus);
|
||||||
epstatus = SET_STALL_TX(epstatus);
|
// epstatus = SET_STALL_TX(epstatus);
|
||||||
} else if (ep.tx_flag){ // package transmitted
|
} else if (ep.tx_flag){ // package transmitted
|
||||||
// now we can change address after enumeration
|
// now we can change address after enumeration
|
||||||
if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){
|
if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){
|
||||||
USB->DADDR = USB_DADDR_EF | USB_Dev.USB_Addr;
|
USB->DADDR = USB_DADDR_EF | USB_Dev.USB_Addr;
|
||||||
// change state to ADRESSED
|
// change state to ADRESSED
|
||||||
USB_Dev.USB_Status = USB_STATE_ADDRESSED;
|
USB_Dev.USB_Status = USB_STATE_ADDRESSED;
|
||||||
|
DBG("Addressed");
|
||||||
}
|
}
|
||||||
// end of transaction
|
// end of transaction
|
||||||
//epstatus = CLEAR_DTOG_RX(epstatus);
|
// epstatus = SET_VALID_RX(epstatus);
|
||||||
//epstatus = CLEAR_DTOG_TX(epstatus);
|
// epstatus = SET_VALID_TX(epstatus);
|
||||||
epstatus = SET_VALID_RX(epstatus);
|
|
||||||
epstatus = SET_VALID_TX(epstatus);
|
|
||||||
}
|
}
|
||||||
|
epstatus = SET_VALID_RX(epstatus);
|
||||||
|
epstatus = SET_VALID_TX(epstatus);
|
||||||
return epstatus;
|
return epstatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,8 +447,8 @@ int EP_Init(uint8_t number, uint8_t type, uint16_t txsz, uint16_t rxsz, uint16_t
|
|||||||
// standard IRQ handler
|
// standard IRQ handler
|
||||||
void usb_lp_can_rx0_isr(){
|
void usb_lp_can_rx0_isr(){
|
||||||
if (USB->ISTR & USB_ISTR_RESET){
|
if (USB->ISTR & USB_ISTR_RESET){
|
||||||
|
DBG("reset");
|
||||||
usbON = 0;
|
usbON = 0;
|
||||||
USB_connected = 0;
|
|
||||||
// Reinit registers
|
// Reinit registers
|
||||||
USB->CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM | USB_CNTR_SUSPM;
|
USB->CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM | USB_CNTR_SUSPM;
|
||||||
// Endpoint 0 - CONTROL
|
// Endpoint 0 - CONTROL
|
||||||
@ -476,7 +487,7 @@ void usb_lp_can_rx0_isr(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{ // IN interrupt - transmit data, only CTR_TX == 1
|
}else{ // IN interrupt - transmit data, only CTR_TX == 1
|
||||||
// enumeration end could be here (if EP0)
|
// enumeration end could be MSG (if EP0)
|
||||||
}
|
}
|
||||||
// prepare status field for EP handler
|
// prepare status field for EP handler
|
||||||
endpoints[n].status = epstatus;
|
endpoints[n].status = epstatus;
|
||||||
|
|||||||
0
F1-nolib/F1_testbrd/pl2303.bin
Normal file → Executable file
0
F1-nolib/F1_testbrd/pl2303.bin
Normal file → Executable file
0
F1-nolib/LED_Screen/LEDscreen.bin
Normal file → Executable file
0
F1-nolib/LED_Screen/LEDscreen.bin
Normal file → Executable file
0
F1-nolib/LED_Screen/genlist
Normal file → Executable file
0
F1-nolib/LED_Screen/genlist
Normal file → Executable file
0
F1-nolib/LED_Screen/scrtest/scrtest
Normal file → Executable file
0
F1-nolib/LED_Screen/scrtest/scrtest
Normal file → Executable file
0
F1-nolib/PL2303/pl2303.bin
Normal file → Executable file
0
F1-nolib/PL2303/pl2303.bin
Normal file → Executable file
0
F1-nolib/SPI/SPI.bin
Normal file → Executable file
0
F1-nolib/SPI/SPI.bin
Normal file → Executable file
0
F1-nolib/USB_HID/usbhid103.bin
Normal file → Executable file
0
F1-nolib/USB_HID/usbhid103.bin
Normal file → Executable file
0
F1-nolib/chronometer/chrono.bin
Normal file → Executable file
0
F1-nolib/chronometer/chrono.bin
Normal file → Executable file
0
F1-nolib/chronometer/depr/chrono.bin
Normal file → Executable file
0
F1-nolib/chronometer/depr/chrono.bin
Normal file → Executable file
0
F1-nolib/chronometer_v2/chrono.bin
Normal file → Executable file
0
F1-nolib/chronometer_v2/chrono.bin
Normal file → Executable file
@ -242,6 +242,8 @@ int main(void){
|
|||||||
sysreset();
|
sysreset();
|
||||||
StartHSE();
|
StartHSE();
|
||||||
SysTick_Config(SYSTICK_DEFCONF); // function SysTick_Config decrements argument!
|
SysTick_Config(SYSTICK_DEFCONF); // function SysTick_Config decrements argument!
|
||||||
|
// read data stored in flash - before all pins/ports setup!!!
|
||||||
|
flashstorage_init();
|
||||||
// !!! hw_setup() should be the first in setup stage
|
// !!! hw_setup() should be the first in setup stage
|
||||||
hw_setup();
|
hw_setup();
|
||||||
USB_setup();
|
USB_setup();
|
||||||
@ -256,8 +258,6 @@ int main(void){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
RCC->CSR |= RCC_CSR_RMVF; // remove reset flags
|
RCC->CSR |= RCC_CSR_RMVF; // remove reset flags
|
||||||
// read data stored in flash
|
|
||||||
flashstorage_init();
|
|
||||||
usarts_setup(); // setup usarts after reading configuration
|
usarts_setup(); // setup usarts after reading configuration
|
||||||
iwdg_setup();
|
iwdg_setup();
|
||||||
|
|
||||||
|
|||||||
0
F1-nolib/led_blink/blink.bin
Normal file → Executable file
0
F1-nolib/led_blink/blink.bin
Normal file → Executable file
0
F1-nolib/uart/uart.bin
Normal file → Executable file
0
F1-nolib/uart/uart.bin
Normal file → Executable file
0
F1/1_wire/onewire.bin
Normal file → Executable file
0
F1/1_wire/onewire.bin
Normal file → Executable file
0
F1/2.8TFT/dma_gpio.bin
Normal file → Executable file
0
F1/2.8TFT/dma_gpio.bin
Normal file → Executable file
0
F1/DMA_GPIO/dma_gpio.bin
Normal file → Executable file
0
F1/DMA_GPIO/dma_gpio.bin
Normal file → Executable file
0
F1/GPIO_TIM/tim_gpio.bin
Normal file → Executable file
0
F1/GPIO_TIM/tim_gpio.bin
Normal file → Executable file
0
F1/GPS+ultrasonic/timelapse.bin
Normal file → Executable file
0
F1/GPS+ultrasonic/timelapse.bin
Normal file → Executable file
0
F1/GPS/GPS.bin
Normal file → Executable file
0
F1/GPS/GPS.bin
Normal file → Executable file
0
F1/Jeep_generator/jeep_generator.bin
Normal file → Executable file
0
F1/Jeep_generator/jeep_generator.bin
Normal file → Executable file
0
F1/Timelapse_keyboard/timelapse.bin
Normal file → Executable file
0
F1/Timelapse_keyboard/timelapse.bin
Normal file → Executable file
0
F1/Timelapse_keyboard_only_lasers/timelapse.bin
Normal file → Executable file
0
F1/Timelapse_keyboard_only_lasers/timelapse.bin
Normal file → Executable file
0
F1/USBCDC_template/usb_cdc_simple.bin
Normal file → Executable file
0
F1/USBCDC_template/usb_cdc_simple.bin
Normal file → Executable file
0
F1/canon_lens/canon_lens.bin
Normal file → Executable file
0
F1/canon_lens/canon_lens.bin
Normal file → Executable file
0
F1/distance_meters/ultrasonic.bin
Normal file → Executable file
0
F1/distance_meters/ultrasonic.bin
Normal file → Executable file
0
F1/hid_mouse_keyboard/usbhid.bin
Normal file → Executable file
0
F1/hid_mouse_keyboard/usbhid.bin
Normal file → Executable file
0
F1/keyboard_snippet/keyboard.bin
Normal file → Executable file
0
F1/keyboard_snippet/keyboard.bin
Normal file → Executable file
0
F1/matrix_keyboard/matrkeyb.bin
Normal file → Executable file
0
F1/matrix_keyboard/matrkeyb.bin
Normal file → Executable file
0
F1/nokia5110/nokia5110.bin
Normal file → Executable file
0
F1/nokia5110/nokia5110.bin
Normal file → Executable file
0
F1/simple_cdc/usb_cdc_simple.bin
Normal file → Executable file
0
F1/simple_cdc/usb_cdc_simple.bin
Normal file → Executable file
0
F1/stepper_motion/usb_cdc_simple.bin
Normal file → Executable file
0
F1/stepper_motion/usb_cdc_simple.bin
Normal file → Executable file
0
F1/ultrasonic/ultrasonic.bin
Normal file → Executable file
0
F1/ultrasonic/ultrasonic.bin
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user