mirror of
https://github.com/eddyem/stm32samples.git
synced 2025-12-06 10:45:11 +03:00
try to add STM32F1 nolib (not working yet)
This commit is contained in:
parent
913b909342
commit
34f6afb702
@ -11,4 +11,5 @@ This directory contains examples for F0 without any library
|
|||||||
- uart - USART over DMA with hardware end-of-string detection
|
- uart - USART over DMA with hardware end-of-string detection
|
||||||
- uart_blink - code for STM32F030F4, echo data on USART1 and blink LEDS on PA4 and PA5
|
- uart_blink - code for STM32F030F4, echo data on USART1 and blink LEDS on PA4 and PA5
|
||||||
- uart_nucleo - USART over DMA for STM32F042-nucleo
|
- uart_nucleo - USART over DMA for STM32F042-nucleo
|
||||||
- usbcdc - CDC for STM32F042 (emulation of ch340)
|
- usbcdc - CDC for STM32F042 (emulation of PL2303) with working CAN bus
|
||||||
|
- ch340 - another CDC (emulation of ch340)
|
||||||
|
|||||||
Binary file not shown.
149
F0-nolib/ch340/Makefile
Normal file
149
F0-nolib/ch340/Makefile
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
BINARY = ch340emul
|
||||||
|
BOOTPORT ?= /dev/ttyUSB0
|
||||||
|
BOOTSPEED ?= 57600
|
||||||
|
# MCU FAMILY
|
||||||
|
FAMILY = F0
|
||||||
|
# MCU code
|
||||||
|
MCU = F042x6
|
||||||
|
# hardware definitions
|
||||||
|
DEFS += -DUSARTNUM=1
|
||||||
|
#DEFS += -DCHECK_TMOUT
|
||||||
|
#DEFS += -DEBUG
|
||||||
|
# change this linking script depending on particular MCU model,
|
||||||
|
# for example, if you have STM32F103VBT6, you should write:
|
||||||
|
LDSCRIPT = ld/stm32f042k.ld
|
||||||
|
|
||||||
|
INDEPENDENT_HEADERS=
|
||||||
|
|
||||||
|
FP_FLAGS ?= -msoft-float
|
||||||
|
ASM_FLAGS = -mthumb -mcpu=cortex-m0 -march=armv6-m -mtune=cortex-m0
|
||||||
|
ARCH_FLAGS = $(ASM_FLAGS) $(FP_FLAGS)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Executables
|
||||||
|
OPREFIX ?= /opt/bin/arm-none-eabi
|
||||||
|
#PREFIX ?= /usr/x86_64-pc-linux-gnu/arm-none-eabi/gcc-bin/7.3.0/arm-none-eabi
|
||||||
|
PREFIX ?= $(OPREFIX)
|
||||||
|
|
||||||
|
RM := rm -f
|
||||||
|
RMDIR := rmdir
|
||||||
|
CC := $(PREFIX)-gcc
|
||||||
|
LD := $(PREFIX)-gcc
|
||||||
|
AR := $(PREFIX)-ar
|
||||||
|
AS := $(PREFIX)-as
|
||||||
|
OBJCOPY := $(OPREFIX)-objcopy
|
||||||
|
OBJDUMP := $(OPREFIX)-objdump
|
||||||
|
GDB := $(OPREFIX)-gdb
|
||||||
|
STFLASH := $(shell which st-flash)
|
||||||
|
STBOOT := $(shell which stm32flash)
|
||||||
|
DFUUTIL := $(shell which dfu-util)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Source files
|
||||||
|
OBJDIR = mk
|
||||||
|
LDSCRIPT ?= $(BINARY).ld
|
||||||
|
SRC := $(wildcard *.c)
|
||||||
|
OBJS := $(addprefix $(OBJDIR)/, $(SRC:%.c=%.o))
|
||||||
|
STARTUP = $(OBJDIR)/startup.o
|
||||||
|
OBJS += $(STARTUP)
|
||||||
|
DEPS := $(OBJS:.o=.d)
|
||||||
|
|
||||||
|
INC_DIR ?= ../inc
|
||||||
|
|
||||||
|
INCLUDE := -I$(INC_DIR)/F0 -I$(INC_DIR)/cm
|
||||||
|
LIB_DIR := $(INC_DIR)/ld
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# C flags
|
||||||
|
CFLAGS += -O2 -g -MD -D__thumb2__=1
|
||||||
|
CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
|
||||||
|
CFLAGS += -Wredundant-decls $(INCLUDE)
|
||||||
|
# -Wmissing-prototypes -Wstrict-prototypes
|
||||||
|
CFLAGS += -fno-common -ffunction-sections -fdata-sections
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Linker flags
|
||||||
|
LDFLAGS += --static -nostartfiles
|
||||||
|
#--specs=nano.specs
|
||||||
|
LDFLAGS += -L$(LIB_DIR)
|
||||||
|
LDFLAGS += -T$(LDSCRIPT)
|
||||||
|
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
|
||||||
|
LDFLAGS += -Wl,--gc-sections
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Used libraries
|
||||||
|
LDLIBS += -Wl,--start-group -lc -lgcc -Wl,--end-group
|
||||||
|
LDLIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
||||||
|
|
||||||
|
DEFS += -DSTM32$(FAMILY) -DSTM32$(MCU)
|
||||||
|
|
||||||
|
#.SUFFIXES: .elf .bin .hex .srec .list .map .images
|
||||||
|
#.SECONDEXPANSION:
|
||||||
|
#.SECONDARY:
|
||||||
|
|
||||||
|
ELF := $(OBJDIR)/$(BINARY).elf
|
||||||
|
LIST := $(OBJDIR)/$(BINARY).list
|
||||||
|
BIN := $(BINARY).bin
|
||||||
|
HEX := $(BINARY).hex
|
||||||
|
|
||||||
|
all: bin list
|
||||||
|
|
||||||
|
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) $(INCLUDE) $(ARCH_FLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.c
|
||||||
|
@echo " CC $<"
|
||||||
|
$(CC) $(CFLAGS) $(DEFS) $(INCLUDE) $(ARCH_FLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
#$(OBJDIR)/%.d: %.c $(OBJDIR)
|
||||||
|
# $(CC) -MM -MG $< | sed -e 's,^\([^:]*\)\.o[ ]*:,$(@D)/\1.o $(@D)/\1.d:,' >$@
|
||||||
|
|
||||||
|
$(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) $(ARCH_FLAGS) $(OBJS) $(LDLIBS) -o $(ELF)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo " CLEAN"
|
||||||
|
$(RM) $(OBJS) $(DEPS) $(ELF) $(HEX) $(LIST) $(OBJDIR)/*.map *.d
|
||||||
|
@rmdir $(OBJDIR) 2>/dev/null || true
|
||||||
|
|
||||||
|
dfuboot: $(BIN)
|
||||||
|
@echo " LOAD $(BIN) THROUGH DFU"
|
||||||
|
$(DFUUTIL) -a0 -D $(BIN) -s 0x08000000
|
||||||
|
|
||||||
|
flash: $(BIN)
|
||||||
|
@echo " FLASH $(BIN)"
|
||||||
|
$(STFLASH) write $(BIN) 0x8000000
|
||||||
|
|
||||||
|
boot: $(BIN)
|
||||||
|
@echo " LOAD $(BIN) through bootloader"
|
||||||
|
$(STBOOT) -b$(BOOTSPEED) $(BOOTPORT) -w $(BIN)
|
||||||
|
|
||||||
|
gentags:
|
||||||
|
CFLAGS="$(CFLAGS) $(DEFS)" geany -g $(BINARY).c.tags *[hc] 2>/dev/null
|
||||||
|
|
||||||
|
.PHONY: clean flash boot gentags
|
||||||
5
F0-nolib/ch340/Readme.md
Normal file
5
F0-nolib/ch340/Readme.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Simple code for USB development board, emulates ch340
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
USB: https://github.com/majbthrd/CDCHIDwidget/blob/master/src/main.c
|
||||||
8
F0-nolib/ch340/ch340.sublime-project
Normal file
8
F0-nolib/ch340/ch340.sublime-project
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"folders":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
548
F0-nolib/ch340/ch340.sublime-workspace
Normal file
548
F0-nolib/ch340/ch340.sublime-workspace
Normal file
File diff suppressed because one or more lines are too long
BIN
F0-nolib/ch340/ch340emul.bin
Executable file
BIN
F0-nolib/ch340/ch340emul.bin
Executable file
Binary file not shown.
49
F0-nolib/ch340/hardware.c
Normal file
49
F0-nolib/ch340/hardware.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* geany_encoding=koi8-r
|
||||||
|
* hardware.c - hardware-dependent macros & functions
|
||||||
|
*
|
||||||
|
* Copyright 2018 Edward V. Emelianov <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "hardware.h"
|
||||||
|
#include "usart.h"
|
||||||
|
|
||||||
|
static uint8_t brdADDR = 0;
|
||||||
|
|
||||||
|
void gpio_setup(void){
|
||||||
|
// here we turn on clocking for all periph.
|
||||||
|
RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN | RCC_AHBENR_GPIOCEN | RCC_AHBENR_DMAEN;
|
||||||
|
// Set LEDS (PC13/14) as output
|
||||||
|
GPIOC->MODER = (GPIOC->MODER & ~(GPIO_MODER_MODER13 | GPIO_MODER_MODER14)
|
||||||
|
) |
|
||||||
|
GPIO_MODER_MODER13_O | GPIO_MODER_MODER14_O;
|
||||||
|
// PB14(0), PB15(1), PA8(2) - board address, pullup inputs
|
||||||
|
GPIOA->PUPDR = (GPIOA->PUPDR & ~(GPIO_PUPDR_PUPDR8)
|
||||||
|
) |
|
||||||
|
GPIO_PUPDR_PUPDR8_0;
|
||||||
|
GPIOB->PUPDR = (GPIOB->PUPDR & ~(GPIO_PUPDR_PUPDR14 | GPIO_PUPDR_PUPDR15)
|
||||||
|
) |
|
||||||
|
GPIO_PUPDR_PUPDR14_0 | GPIO_PUPDR_PUPDR15_0;
|
||||||
|
pin_set(LED0_port, LED0_pin); // clear LEDs
|
||||||
|
pin_set(LED1_port, LED1_pin);
|
||||||
|
uint8_t addr = READ_BRD_INV_ADDR();
|
||||||
|
brdADDR = ~addr & 0x7;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t getBRDaddr(){return brdADDR;}
|
||||||
56
F0-nolib/ch340/hardware.h
Normal file
56
F0-nolib/ch340/hardware.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* geany_encoding=koi8-r
|
||||||
|
* hardware.h
|
||||||
|
*
|
||||||
|
* Copyright 2018 Edward V. Emelianov <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#ifndef __HARDWARE_H__
|
||||||
|
#define __HARDWARE_H__
|
||||||
|
|
||||||
|
#include "stm32f0.h"
|
||||||
|
|
||||||
|
#define CONCAT(a,b) a ## b
|
||||||
|
#define STR_HELPER(s) #s
|
||||||
|
#define STR(s) STR_HELPER(s)
|
||||||
|
|
||||||
|
#define FORMUSART(X) CONCAT(USART, X)
|
||||||
|
#define USARTX FORMUSART(USARTNUM)
|
||||||
|
|
||||||
|
// LEDS: 0 - PC13, 1 - PC14
|
||||||
|
// LED0
|
||||||
|
#define LED0_port GPIOC
|
||||||
|
#define LED0_pin (1<<13)
|
||||||
|
// LED1
|
||||||
|
#define LED1_port GPIOC
|
||||||
|
#define LED1_pin (1<<14)
|
||||||
|
|
||||||
|
#define LED_blink(x) pin_toggle(x ## _port, x ## _pin)
|
||||||
|
#define LED_on(x) pin_clear(x ## _port, x ## _pin)
|
||||||
|
#define LED_off(x) pin_set(x ## _port, x ## _pin)
|
||||||
|
|
||||||
|
|
||||||
|
// Board address - PB14(0), PB15(1), PA8(2)
|
||||||
|
#define READ_BRD_INV_ADDR() (((GPIOA->IDR & (1<<8))>>6)|((GPIOB->IDR & (3<<14))>>14))
|
||||||
|
|
||||||
|
void gpio_setup(void);
|
||||||
|
|
||||||
|
uint8_t getBRDaddr();
|
||||||
|
|
||||||
|
#endif // __HARDWARE_H__
|
||||||
12
F0-nolib/ch340/ld/stm32f042k.ld
Normal file
12
F0-nolib/ch340/ld/stm32f042k.ld
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/* Linker script for STM32F042x6, 32K flash, 6K RAM. */
|
||||||
|
|
||||||
|
/* Define memory regions. */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
rom (rx) : ORIGIN = 0x08000000, LENGTH = 32K
|
||||||
|
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 6K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Include the common ld script. */
|
||||||
|
INCLUDE stm32f0.ld
|
||||||
|
|
||||||
69
F0-nolib/ch340/lsusb_log
Normal file
69
F0-nolib/ch340/lsusb_log
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
|
||||||
|
Bus 002 Device 005: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
|
||||||
|
Device Descriptor:
|
||||||
|
bLength 18
|
||||||
|
bDescriptorType 1
|
||||||
|
bcdUSB 1.10
|
||||||
|
bDeviceClass 255 Vendor Specific Class
|
||||||
|
bDeviceSubClass 0
|
||||||
|
bDeviceProtocol 0
|
||||||
|
bMaxPacketSize0 8
|
||||||
|
idVendor 0x1a86 QinHeng Electronics
|
||||||
|
idProduct 0x7523 HL-340 USB-Serial adapter
|
||||||
|
bcdDevice 2.54
|
||||||
|
iManufacturer 0
|
||||||
|
iProduct 2 USB2.0-Serial
|
||||||
|
iSerial 0
|
||||||
|
bNumConfigurations 1
|
||||||
|
Configuration Descriptor:
|
||||||
|
bLength 9
|
||||||
|
bDescriptorType 2
|
||||||
|
wTotalLength 39
|
||||||
|
bNumInterfaces 1
|
||||||
|
bConfigurationValue 1
|
||||||
|
iConfiguration 0
|
||||||
|
bmAttributes 0x80
|
||||||
|
(Bus Powered)
|
||||||
|
MaxPower 96mA
|
||||||
|
Interface Descriptor:
|
||||||
|
bLength 9
|
||||||
|
bDescriptorType 4
|
||||||
|
bInterfaceNumber 0
|
||||||
|
bAlternateSetting 0
|
||||||
|
bNumEndpoints 3
|
||||||
|
bInterfaceClass 255 Vendor Specific Class
|
||||||
|
bInterfaceSubClass 1
|
||||||
|
bInterfaceProtocol 2
|
||||||
|
iInterface 0
|
||||||
|
Endpoint Descriptor:
|
||||||
|
bLength 7
|
||||||
|
bDescriptorType 5
|
||||||
|
bEndpointAddress 0x82 EP 2 IN
|
||||||
|
bmAttributes 2
|
||||||
|
Transfer Type Bulk
|
||||||
|
Synch Type None
|
||||||
|
Usage Type Data
|
||||||
|
wMaxPacketSize 0x0020 1x 32 bytes
|
||||||
|
bInterval 0
|
||||||
|
Endpoint Descriptor:
|
||||||
|
bLength 7
|
||||||
|
bDescriptorType 5
|
||||||
|
bEndpointAddress 0x02 EP 2 OUT
|
||||||
|
bmAttributes 2
|
||||||
|
Transfer Type Bulk
|
||||||
|
Synch Type None
|
||||||
|
Usage Type Data
|
||||||
|
wMaxPacketSize 0x0020 1x 32 bytes
|
||||||
|
bInterval 0
|
||||||
|
Endpoint Descriptor:
|
||||||
|
bLength 7
|
||||||
|
bDescriptorType 5
|
||||||
|
bEndpointAddress 0x81 EP 1 IN
|
||||||
|
bmAttributes 3
|
||||||
|
Transfer Type Interrupt
|
||||||
|
Synch Type None
|
||||||
|
Usage Type Data
|
||||||
|
wMaxPacketSize 0x0008 1x 8 bytes
|
||||||
|
bInterval 1
|
||||||
|
Device Status: 0x0000
|
||||||
|
(Bus Powered)
|
||||||
131
F0-nolib/ch340/main.c
Normal file
131
F0-nolib/ch340/main.c
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* main.c
|
||||||
|
*
|
||||||
|
* Copyright 2017 Edward V. Emelianoff <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "hardware.h"
|
||||||
|
#include "usart.h"
|
||||||
|
#include "usb.h"
|
||||||
|
#include "usb_lib.h"
|
||||||
|
|
||||||
|
volatile uint32_t Tms = 0;
|
||||||
|
|
||||||
|
/* Called when systick fires */
|
||||||
|
void sys_tick_handler(void){
|
||||||
|
++Tms;
|
||||||
|
}
|
||||||
|
|
||||||
|
void iwdg_setup(){
|
||||||
|
uint32_t tmout = 16000000;
|
||||||
|
/* Enable the peripheral clock RTC */
|
||||||
|
/* (1) Enable the LSI (40kHz) */
|
||||||
|
/* (2) Wait while it is not ready */
|
||||||
|
RCC->CSR |= RCC_CSR_LSION; /* (1) */
|
||||||
|
while((RCC->CSR & RCC_CSR_LSIRDY) != RCC_CSR_LSIRDY){if(--tmout == 0) break;} /* (2) */
|
||||||
|
/* Configure IWDG */
|
||||||
|
/* (1) Activate IWDG (not needed if done in option bytes) */
|
||||||
|
/* (2) Enable write access to IWDG registers */
|
||||||
|
/* (3) Set prescaler by 64 (1.6ms for each tick) */
|
||||||
|
/* (4) Set reload value to have a rollover each 2s */
|
||||||
|
/* (5) Check if flags are reset */
|
||||||
|
/* (6) Refresh counter */
|
||||||
|
IWDG->KR = IWDG_START; /* (1) */
|
||||||
|
IWDG->KR = IWDG_WRITE_ACCESS; /* (2) */
|
||||||
|
IWDG->PR = IWDG_PR_PR_1; /* (3) */
|
||||||
|
IWDG->RLR = 1250; /* (4) */
|
||||||
|
tmout = 16000000;
|
||||||
|
while(IWDG->SR){if(--tmout == 0) break;} /* (5) */
|
||||||
|
IWDG->KR = IWDG_REFRESH; /* (6) */
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void){
|
||||||
|
uint32_t lastT = 0;
|
||||||
|
int L;
|
||||||
|
char *txt;
|
||||||
|
sysreset();
|
||||||
|
SysTick_Config(6000, 1);
|
||||||
|
gpio_setup();
|
||||||
|
usart_setup();
|
||||||
|
//iwdg_setup();
|
||||||
|
|
||||||
|
SEND("Greetings! My address is ");
|
||||||
|
printuhex(getBRDaddr());
|
||||||
|
newline();
|
||||||
|
|
||||||
|
if(RCC->CSR & RCC_CSR_IWDGRSTF){ // watchdog reset occured
|
||||||
|
SEND("WDGRESET=1\n");
|
||||||
|
}
|
||||||
|
if(RCC->CSR & RCC_CSR_SFTRSTF){ // software reset occured
|
||||||
|
SEND("SOFTRESET=1\n");
|
||||||
|
}
|
||||||
|
RCC->CSR |= RCC_CSR_RMVF; // remove reset flags
|
||||||
|
|
||||||
|
USB_setup();
|
||||||
|
|
||||||
|
while (1){
|
||||||
|
IWDG->KR = IWDG_REFRESH; // refresh watchdog
|
||||||
|
if(lastT > Tms || Tms - lastT > 499){
|
||||||
|
LED_blink(LED0);
|
||||||
|
lastT = Tms;
|
||||||
|
transmit_tbuf(); // non-blocking transmission of data from UART buffer every 0.5s
|
||||||
|
}
|
||||||
|
usb_proc();
|
||||||
|
if(usartrx()){ // usart1 received data, store in in buffer
|
||||||
|
L = usart_getline(&txt);
|
||||||
|
char _1st = txt[0];
|
||||||
|
if(L == 2 && txt[1] == '\n'){
|
||||||
|
L = 0;
|
||||||
|
switch(_1st){
|
||||||
|
case 'A':
|
||||||
|
SEND("Board address: ");
|
||||||
|
printuhex(getBRDaddr());
|
||||||
|
newline();
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
SEND("Soft reset\n");
|
||||||
|
NVIC_SystemReset();
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
USB_send("Test string for USB\n");
|
||||||
|
break;
|
||||||
|
case 'W':
|
||||||
|
SEND("Wait for reboot\n");
|
||||||
|
while(1){nop();};
|
||||||
|
break;
|
||||||
|
default: // help
|
||||||
|
SEND(
|
||||||
|
"'A' - get CAN address\n"
|
||||||
|
"'R' - software reset\n"
|
||||||
|
"'U' - send test string over USB\n"
|
||||||
|
"'W' - test watchdog\n"
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
transmit_tbuf();
|
||||||
|
}
|
||||||
|
if(L){ // echo all other data
|
||||||
|
txt[L] = 0;
|
||||||
|
usart_send(txt);
|
||||||
|
L = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
267
F0-nolib/ch340/usart.c
Normal file
267
F0-nolib/ch340/usart.c
Normal file
@ -0,0 +1,267 @@
|
|||||||
|
/*
|
||||||
|
* usart.c
|
||||||
|
*
|
||||||
|
* Copyright 2017 Edward V. Emelianoff <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
#include "stm32f0.h"
|
||||||
|
#include "hardware.h"
|
||||||
|
#include "usart.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
extern volatile uint32_t Tms;
|
||||||
|
static volatile int idatalen[2] = {0,0}; // received data line length (including '\n')
|
||||||
|
static volatile int odatalen[2] = {0,0};
|
||||||
|
|
||||||
|
volatile int linerdy = 0, // received data ready
|
||||||
|
dlen = 0, // length of data (including '\n') in current buffer
|
||||||
|
bufovr = 0, // input buffer overfull
|
||||||
|
txrdy = 1 // transmission done
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
int rbufno = 0, tbufno = 0; // current rbuf/tbuf numbers
|
||||||
|
static char rbuf[2][UARTBUFSZI], tbuf[2][UARTBUFSZO]; // receive & transmit buffers
|
||||||
|
static char *recvdata = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return length of received data (without trailing zero
|
||||||
|
*/
|
||||||
|
int usart_getline(char **line){
|
||||||
|
if(bufovr){
|
||||||
|
bufovr = 0;
|
||||||
|
linerdy = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*line = recvdata;
|
||||||
|
linerdy = 0;
|
||||||
|
return dlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
// transmit current tbuf and swap buffers
|
||||||
|
void transmit_tbuf(){
|
||||||
|
uint32_t tmout = 16000000;
|
||||||
|
while(!txrdy){if(--tmout == 0) break;}; // wait for previos buffer transmission
|
||||||
|
register int l = odatalen[tbufno];
|
||||||
|
if(!l) return;
|
||||||
|
txrdy = 0;
|
||||||
|
odatalen[tbufno] = 0;
|
||||||
|
#if USARTNUM == 2
|
||||||
|
DMA1_Channel4->CCR &= ~DMA_CCR_EN;
|
||||||
|
DMA1_Channel4->CMAR = (uint32_t) tbuf[tbufno]; // mem
|
||||||
|
DMA1_Channel4->CNDTR = l;
|
||||||
|
DMA1_Channel4->CCR |= DMA_CCR_EN; // start transmission
|
||||||
|
#elif USARTNUM == 1
|
||||||
|
DMA1_Channel2->CCR &= ~DMA_CCR_EN;
|
||||||
|
DMA1_Channel2->CMAR = (uint32_t) tbuf[tbufno]; // mem
|
||||||
|
DMA1_Channel2->CNDTR = l;
|
||||||
|
DMA1_Channel2->CCR |= DMA_CCR_EN;
|
||||||
|
#else
|
||||||
|
#error "Not implemented"
|
||||||
|
#endif
|
||||||
|
tbufno = !tbufno;
|
||||||
|
}
|
||||||
|
|
||||||
|
void usart_putchar(const char ch){
|
||||||
|
if(odatalen[tbufno] == UARTBUFSZO) transmit_tbuf();
|
||||||
|
tbuf[tbufno][odatalen[tbufno]++] = ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
void usart_send(const char *str){
|
||||||
|
uint32_t x = 512;
|
||||||
|
while(*str && --x){
|
||||||
|
if(odatalen[tbufno] == UARTBUFSZO) transmit_tbuf();
|
||||||
|
tbuf[tbufno][odatalen[tbufno]++] = *str++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void newline(){
|
||||||
|
usart_putchar('\n');
|
||||||
|
transmit_tbuf();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void usart_setup(){
|
||||||
|
// Nucleo's USART2 connected to VCP proxy of st-link
|
||||||
|
uint32_t tmout = 16000000;
|
||||||
|
#if USARTNUM == 2
|
||||||
|
// setup pins: PA2 (Tx - AF1), PA15 (Rx - AF1)
|
||||||
|
// AF mode (AF1)
|
||||||
|
GPIOA->MODER = (GPIOA->MODER & ~(GPIO_MODER_MODER2|GPIO_MODER_MODER15))\
|
||||||
|
| (GPIO_MODER_MODER2_AF | GPIO_MODER_MODER15_AF);
|
||||||
|
GPIOA->AFR[0] = (GPIOA->AFR[0] &~GPIO_AFRH_AFRH2) | 1 << (2 * 4); // PA2
|
||||||
|
GPIOA->AFR[1] = (GPIOA->AFR[1] &~GPIO_AFRH_AFRH7) | 1 << (7 * 4); // PA15
|
||||||
|
// DMA: Tx - Ch4
|
||||||
|
DMA1_Channel4->CPAR = (uint32_t) &USART2->TDR; // periph
|
||||||
|
DMA1_Channel4->CCR |= DMA_CCR_MINC | DMA_CCR_DIR | DMA_CCR_TCIE; // 8bit, mem++, mem->per, transcompl irq
|
||||||
|
// Tx CNDTR set @ each transmission due to data size
|
||||||
|
NVIC_SetPriority(DMA1_Channel4_5_IRQn, 3);
|
||||||
|
NVIC_EnableIRQ(DMA1_Channel4_5_IRQn);
|
||||||
|
NVIC_SetPriority(USART2_IRQn, 0);
|
||||||
|
// setup usart2
|
||||||
|
RCC->APB1ENR |= RCC_APB1ENR_USART2EN; // clock
|
||||||
|
// oversampling by16, 115200bps (fck=48mHz)
|
||||||
|
//USART2_BRR = 0x1a1; // 48000000 / 115200
|
||||||
|
USART2->BRR = 480000 / 1152;
|
||||||
|
USART2->CR3 = USART_CR3_DMAT; // enable DMA Tx
|
||||||
|
USART2->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_UE; // 1start,8data,nstop; enable Rx,Tx,USART
|
||||||
|
while(!(USART2->ISR & USART_ISR_TC)){if(--tmout == 0) break;} // polling idle frame Transmission
|
||||||
|
USART2->ICR |= USART_ICR_TCCF; // clear TC flag
|
||||||
|
USART2->CR1 |= USART_CR1_RXNEIE;
|
||||||
|
NVIC_EnableIRQ(USART2_IRQn);
|
||||||
|
// USART1 of main board
|
||||||
|
#elif USARTNUM == 1
|
||||||
|
// PA9 - Tx, PA10 - Rx (AF1)
|
||||||
|
GPIOA->MODER = (GPIOA->MODER & ~(GPIO_MODER_MODER9 | GPIO_MODER_MODER10))\
|
||||||
|
| (GPIO_MODER_MODER9_AF | GPIO_MODER_MODER10_AF);
|
||||||
|
GPIOA->AFR[1] = (GPIOA->AFR[1] & ~(GPIO_AFRH_AFRH1 | GPIO_AFRH_AFRH2)) |
|
||||||
|
1 << (1 * 4) | 1 << (2 * 4); // PA9, PA10
|
||||||
|
// USART1 Tx DMA - Channel2 (default value in SYSCFG_CFGR1)
|
||||||
|
DMA1_Channel2->CPAR = (uint32_t) &USART1->TDR; // periph
|
||||||
|
DMA1_Channel2->CMAR = (uint32_t) tbuf; // mem
|
||||||
|
DMA1_Channel2->CCR |= DMA_CCR_MINC | DMA_CCR_DIR | DMA_CCR_TCIE; // 8bit, mem++, mem->per, transcompl irq
|
||||||
|
// Tx CNDTR set @ each transmission due to data size
|
||||||
|
NVIC_SetPriority(DMA1_Channel2_3_IRQn, 3);
|
||||||
|
NVIC_EnableIRQ(DMA1_Channel2_3_IRQn);
|
||||||
|
NVIC_SetPriority(USART1_IRQn, 0);
|
||||||
|
// setup usart1
|
||||||
|
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
|
||||||
|
USART1->BRR = 480000 / 1152;
|
||||||
|
USART1->CR3 = USART_CR3_DMAT; // enable DMA Tx
|
||||||
|
USART1->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_UE; // 1start,8data,nstop; enable Rx,Tx,USART
|
||||||
|
while(!(USART1->ISR & USART_ISR_TC)){if(--tmout == 0) break;} // polling idle frame Transmission
|
||||||
|
USART1->ICR |= USART_ICR_TCCF; // clear TC flag
|
||||||
|
USART1->CR1 |= USART_CR1_RXNEIE;
|
||||||
|
NVIC_EnableIRQ(USART1_IRQn);
|
||||||
|
#else
|
||||||
|
#error "Not implemented"
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if USARTNUM == 2
|
||||||
|
void usart2_isr(){
|
||||||
|
// USART1
|
||||||
|
#elif USARTNUM == 1
|
||||||
|
void usart1_isr(){
|
||||||
|
#else
|
||||||
|
#error "Not implemented"
|
||||||
|
#endif
|
||||||
|
#ifdef CHECK_TMOUT
|
||||||
|
static uint32_t tmout = 0;
|
||||||
|
#endif
|
||||||
|
if(USARTX->ISR & USART_ISR_RXNE){ // RX not emty - receive next char
|
||||||
|
#ifdef CHECK_TMOUT
|
||||||
|
if(tmout && Tms >= tmout){ // set overflow flag
|
||||||
|
bufovr = 1;
|
||||||
|
idatalen[rbufno] = 0;
|
||||||
|
}
|
||||||
|
tmout = Tms + TIMEOUT_MS;
|
||||||
|
if(!tmout) tmout = 1; // prevent 0
|
||||||
|
#endif
|
||||||
|
// read RDR clears flag
|
||||||
|
uint8_t rb = USARTX->RDR;
|
||||||
|
if(idatalen[rbufno] < UARTBUFSZI){ // put next char into buf
|
||||||
|
rbuf[rbufno][idatalen[rbufno]++] = rb;
|
||||||
|
if(rb == '\n'){ // got newline - line ready
|
||||||
|
linerdy = 1;
|
||||||
|
dlen = idatalen[rbufno];
|
||||||
|
recvdata = rbuf[rbufno];
|
||||||
|
// prepare other buffer
|
||||||
|
rbufno = !rbufno;
|
||||||
|
idatalen[rbufno] = 0;
|
||||||
|
#ifdef CHECK_TMOUT
|
||||||
|
// clear timeout at line end
|
||||||
|
tmout = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}else{ // buffer overrun
|
||||||
|
bufovr = 1;
|
||||||
|
idatalen[rbufno] = 0;
|
||||||
|
#ifdef CHECK_TMOUT
|
||||||
|
tmout = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// print 32bit unsigned int
|
||||||
|
void printu(uint32_t val){
|
||||||
|
char bufa[11], bufb[10];
|
||||||
|
int l = 0, bpos = 0;
|
||||||
|
if(!val){
|
||||||
|
bufa[0] = '0';
|
||||||
|
l = 1;
|
||||||
|
}else{
|
||||||
|
while(val){
|
||||||
|
bufb[l++] = val % 10 + '0';
|
||||||
|
val /= 10;
|
||||||
|
}
|
||||||
|
int i;
|
||||||
|
bpos += l;
|
||||||
|
for(i = 0; i < l; ++i){
|
||||||
|
bufa[--bpos] = bufb[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bufa[l + bpos] = 0;
|
||||||
|
usart_send(bufa);
|
||||||
|
}
|
||||||
|
|
||||||
|
// print 32bit unsigned int as hex
|
||||||
|
void printuhex(uint32_t val){
|
||||||
|
usart_send("0x");
|
||||||
|
uint8_t *ptr = (uint8_t*)&val + 3;
|
||||||
|
int i, j;
|
||||||
|
for(i = 0; i < 4; ++i, --ptr){
|
||||||
|
for(j = 1; j > -1; --j){
|
||||||
|
register uint8_t half = (*ptr >> (4*j)) & 0x0f;
|
||||||
|
if(half < 10) usart_putchar(half + '0');
|
||||||
|
else usart_putchar(half - 10 + 'a');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// dump memory buffer
|
||||||
|
void hexdump(uint8_t *arr, uint16_t len){
|
||||||
|
for(uint16_t l = 0; l < len; ++l, ++arr){
|
||||||
|
for(int16_t j = 1; j > -1; --j){
|
||||||
|
register uint8_t half = (*arr >> (4*j)) & 0x0f;
|
||||||
|
if(half < 10) usart_putchar(half + '0');
|
||||||
|
else usart_putchar(half - 10 + 'a');
|
||||||
|
}
|
||||||
|
if(l % 16 == 15) usart_putchar('\n');
|
||||||
|
else if(l & 1) usart_putchar(' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if USARTNUM == 2
|
||||||
|
void dma1_channel4_5_isr(){
|
||||||
|
if(DMA1->ISR & DMA_ISR_TCIF4){ // Tx
|
||||||
|
DMA1->IFCR |= DMA_IFCR_CTCIF4; // clear TC flag
|
||||||
|
txrdy = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// USART1
|
||||||
|
#elif USARTNUM == 1
|
||||||
|
void dma1_channel2_3_isr(){
|
||||||
|
if(DMA1->ISR & DMA_ISR_TCIF2){ // Tx
|
||||||
|
DMA1->IFCR |= DMA_IFCR_CTCIF2; // clear TC flag
|
||||||
|
txrdy = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#error "Not implemented"
|
||||||
|
#endif
|
||||||
59
F0-nolib/ch340/usart.h
Normal file
59
F0-nolib/ch340/usart.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* usart.h
|
||||||
|
*
|
||||||
|
* Copyright 2017 Edward V. Emelianoff <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#ifndef __USART_H__
|
||||||
|
#define __USART_H__
|
||||||
|
|
||||||
|
#include "hardware.h"
|
||||||
|
|
||||||
|
// input and output buffers size
|
||||||
|
#define UARTBUFSZI (32)
|
||||||
|
#define UARTBUFSZO (512)
|
||||||
|
// timeout between data bytes
|
||||||
|
#ifndef TIMEOUT_MS
|
||||||
|
#define TIMEOUT_MS (1500)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// macro for static strings
|
||||||
|
#define SEND(str) usart_send(str)
|
||||||
|
|
||||||
|
#ifdef EBUG
|
||||||
|
#define MSG(str) do{SEND(__FILE__ " (L" STR(__LINE__) "): " str);}while(0)
|
||||||
|
#else
|
||||||
|
#define MSG(str)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define usartrx() (linerdy)
|
||||||
|
#define usartovr() (bufovr)
|
||||||
|
|
||||||
|
extern volatile int linerdy, bufovr, txrdy;
|
||||||
|
|
||||||
|
void transmit_tbuf();
|
||||||
|
void usart_setup();
|
||||||
|
int usart_getline(char **line);
|
||||||
|
void usart_send(const char *str);
|
||||||
|
void newline();
|
||||||
|
void usart_putchar(const char ch);
|
||||||
|
void printu(uint32_t val);
|
||||||
|
void printuhex(uint32_t val);
|
||||||
|
void hexdump(uint8_t *arr, uint16_t len);
|
||||||
|
|
||||||
|
#endif // __USART_H__
|
||||||
128
F0-nolib/ch340/usb.c
Normal file
128
F0-nolib/ch340/usb.c
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* geany_encoding=koi8-r
|
||||||
|
* usb.c
|
||||||
|
*
|
||||||
|
* Copyright 2018 Edward V. Emelianov <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "usb.h"
|
||||||
|
#include "usb_lib.h"
|
||||||
|
#include "usart.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t buffer[BUFFSIZE+1];
|
||||||
|
static uint8_t len, rcvflag = 0;
|
||||||
|
|
||||||
|
// interrupt IN handler (never used?)
|
||||||
|
static uint16_t EP1_Handler(ep_t ep){
|
||||||
|
if (ep.rx_flag){
|
||||||
|
EP_Read(1, buffer);
|
||||||
|
ep.status = SET_VALID_TX(ep.status);
|
||||||
|
ep.status = KEEP_STAT_RX(ep.status);
|
||||||
|
} else
|
||||||
|
if (ep.tx_flag){
|
||||||
|
ep.status = SET_VALID_RX(ep.status);
|
||||||
|
ep.status = SET_STALL_TX(ep.status);
|
||||||
|
}
|
||||||
|
return ep.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// data IN/OUT handler
|
||||||
|
static uint16_t EP2_Handler(ep_t ep){
|
||||||
|
if(ep.rx_flag){
|
||||||
|
if(ep.rx_cnt > 0 && ep.rx_cnt < BUFFSIZE){
|
||||||
|
rcvflag = 1;
|
||||||
|
len = EP_Read(2, buffer);
|
||||||
|
buffer[len] = 0;
|
||||||
|
#ifdef EBUG
|
||||||
|
MSG("read: ");
|
||||||
|
if(len) SEND((char*)buffer);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
// end of transaction: clear DTOGs
|
||||||
|
ep.status = CLEAR_DTOG_RX(ep.status);
|
||||||
|
ep.status = CLEAR_DTOG_TX(ep.status);
|
||||||
|
ep.status = SET_STALL_TX(ep.status);
|
||||||
|
}else if (ep.tx_flag){
|
||||||
|
ep.status = KEEP_STAT_TX(ep.status);
|
||||||
|
}
|
||||||
|
ep.status = SET_VALID_RX(ep.status);
|
||||||
|
return ep.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void USB_setup(){
|
||||||
|
RCC->APB1ENR |= RCC_APB1ENR_CRSEN | RCC_APB1ENR_USBEN; // enable CRS (hsi48 sync) & USB
|
||||||
|
RCC->CFGR3 &= ~RCC_CFGR3_USBSW; // reset USB
|
||||||
|
RCC->CR2 |= RCC_CR2_HSI48ON; // turn ON HSI48
|
||||||
|
uint32_t tmout = 16000000;
|
||||||
|
while(!(RCC->CR2 & RCC_CR2_HSI48RDY)){if(--tmout == 0) break;}
|
||||||
|
FLASH->ACR = FLASH_ACR_PRFTBE | FLASH_ACR_LATENCY;
|
||||||
|
CRS->CFGR &= ~CRS_CFGR_SYNCSRC;
|
||||||
|
CRS->CFGR |= CRS_CFGR_SYNCSRC_1; // USB SOF selected as sync source
|
||||||
|
CRS->CR |= CRS_CR_AUTOTRIMEN; // enable auto trim
|
||||||
|
CRS->CR |= CRS_CR_CEN; // enable freq counter & block CRS->CFGR as read-only
|
||||||
|
RCC->CFGR |= RCC_CFGR_SW;
|
||||||
|
// allow RESET and CTRM interrupts
|
||||||
|
USB->CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM;
|
||||||
|
// clear flags
|
||||||
|
USB->ISTR = 0;
|
||||||
|
// and activate pullup
|
||||||
|
USB->BCDR |= USB_BCDR_DPPU;
|
||||||
|
NVIC_EnableIRQ(USB_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void usb_proc(){
|
||||||
|
static int8_t usbON = 0;
|
||||||
|
if(USB_GetState() == USB_CONFIGURE_STATE){ // USB configured - activate other endpoints
|
||||||
|
if(!usbON){ // endpoints not activated
|
||||||
|
MSG("Configured; activate other endpoints\n");
|
||||||
|
// make new BULK endpoint
|
||||||
|
// Buffer have 1024 bytes, but last 256 we use for CAN bus
|
||||||
|
// first free is 64; 768 - CAN data
|
||||||
|
// free: 64 128 192 256 320 384 448 512 576 640 704
|
||||||
|
// (first 192 free bytes are for EP0)
|
||||||
|
EP_Init(1, EP_TYPE_INTERRUPT, 192, 192, EP1_Handler);
|
||||||
|
EP_Init(2, EP_TYPE_BULK, 256, 320, EP2_Handler); // IN/OUT
|
||||||
|
usbON = 1;
|
||||||
|
}else{
|
||||||
|
if(rcvflag){
|
||||||
|
/*
|
||||||
|
* don't process received data here: if it would come too fast you will loose a part
|
||||||
|
* It would be a good idea to collect incoming data in greater buffer and process it
|
||||||
|
* later (EX: echo "text" > /dev/ttyUSB1 will split into two writings!
|
||||||
|
*/
|
||||||
|
rcvflag = 0;
|
||||||
|
}
|
||||||
|
if(SETLINECODING()){
|
||||||
|
SEND("got new linecoding");
|
||||||
|
CLRLINECODING();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
usbON = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void USB_send(char *buf){
|
||||||
|
uint16_t l = 0;
|
||||||
|
char *p = buf;
|
||||||
|
while(*p++) ++l;
|
||||||
|
EP_Write(3, (uint8_t*)buf, l);
|
||||||
|
}
|
||||||
35
F0-nolib/ch340/usb.h
Normal file
35
F0-nolib/ch340/usb.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* geany_encoding=koi8-r
|
||||||
|
* usb.h
|
||||||
|
*
|
||||||
|
* Copyright 2018 Edward V. Emelianov <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#ifndef __USB_H__
|
||||||
|
#define __USB_H__
|
||||||
|
|
||||||
|
#include "hardware.h"
|
||||||
|
|
||||||
|
#define BUFFSIZE (64)
|
||||||
|
|
||||||
|
void USB_setup();
|
||||||
|
void usb_proc();
|
||||||
|
void USB_send(char *buf);
|
||||||
|
|
||||||
|
#endif // __USB_H__
|
||||||
92
F0-nolib/ch340/usb_defs.h
Normal file
92
F0-nolib/ch340/usb_defs.h
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* geany_encoding=koi8-r
|
||||||
|
* usb_defs.h
|
||||||
|
*
|
||||||
|
* Copyright 2018 Edward V. Emelianov <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef __USB_DEFS_H__
|
||||||
|
#define __USB_DEFS_H__
|
||||||
|
|
||||||
|
#include <stm32f0xx.h>
|
||||||
|
|
||||||
|
#define USB_BTABLE_BASE 0x40006000
|
||||||
|
#undef USB_BTABLE
|
||||||
|
#define USB_BTABLE ((USB_BtableDef *)(USB_BTABLE_BASE))
|
||||||
|
#define USB_ISTR_EPID 0x0000000F
|
||||||
|
#define USB_FNR_LSOF_0 0x00000800
|
||||||
|
#define USB_FNR_lSOF_1 0x00001000
|
||||||
|
#define USB_LPMCSR_BESL_0 0x00000010
|
||||||
|
#define USB_LPMCSR_BESL_1 0x00000020
|
||||||
|
#define USB_LPMCSR_BESL_2 0x00000040
|
||||||
|
#define USB_LPMCSR_BESL_3 0x00000080
|
||||||
|
#define USB_EPnR_CTR_RX 0x00008000
|
||||||
|
#define USB_EPnR_DTOG_RX 0x00004000
|
||||||
|
#define USB_EPnR_STAT_RX 0x00003000
|
||||||
|
#define USB_EPnR_STAT_RX_0 0x00001000
|
||||||
|
#define USB_EPnR_STAT_RX_1 0x00002000
|
||||||
|
#define USB_EPnR_SETUP 0x00000800
|
||||||
|
#define USB_EPnR_EP_TYPE 0x00000600
|
||||||
|
#define USB_EPnR_EP_TYPE_0 0x00000200
|
||||||
|
#define USB_EPnR_EP_TYPE_1 0x00000400
|
||||||
|
#define USB_EPnR_EP_KIND 0x00000100
|
||||||
|
#define USB_EPnR_CTR_TX 0x00000080
|
||||||
|
#define USB_EPnR_DTOG_TX 0x00000040
|
||||||
|
#define USB_EPnR_STAT_TX 0x00000030
|
||||||
|
#define USB_EPnR_STAT_TX_0 0x00000010
|
||||||
|
#define USB_EPnR_STAT_TX_1 0x00000020
|
||||||
|
#define USB_EPnR_EA 0x0000000F
|
||||||
|
#define USB_COUNTn_RX_BLSIZE 0x00008000
|
||||||
|
#define USB_COUNTn_NUM_BLOCK 0x00007C00
|
||||||
|
#define USB_COUNTn_RX 0x0000003F
|
||||||
|
|
||||||
|
#define USB_TypeDef USB_TypeDef_custom
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
__IO uint32_t EPnR[8];
|
||||||
|
__IO uint32_t RESERVED1;
|
||||||
|
__IO uint32_t RESERVED2;
|
||||||
|
__IO uint32_t RESERVED3;
|
||||||
|
__IO uint32_t RESERVED4;
|
||||||
|
__IO uint32_t RESERVED5;
|
||||||
|
__IO uint32_t RESERVED6;
|
||||||
|
__IO uint32_t RESERVED7;
|
||||||
|
__IO uint32_t RESERVED8;
|
||||||
|
__IO uint32_t CNTR;
|
||||||
|
__IO uint32_t ISTR;
|
||||||
|
__IO uint32_t FNR;
|
||||||
|
__IO uint32_t DADDR;
|
||||||
|
__IO uint32_t BTABLE;
|
||||||
|
__IO uint32_t LPMCSR;
|
||||||
|
__IO uint32_t BCDR;
|
||||||
|
} USB_TypeDef;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
__IO uint16_t USB_ADDR_TX;
|
||||||
|
__IO uint16_t USB_COUNT_TX;
|
||||||
|
__IO uint16_t USB_ADDR_RX;
|
||||||
|
__IO uint16_t USB_COUNT_RX;
|
||||||
|
} USB_EPDATA_TypeDef;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
__IO USB_EPDATA_TypeDef EP[8];
|
||||||
|
} USB_BtableDef;
|
||||||
|
|
||||||
|
#endif // __USB_DEFS_H__
|
||||||
480
F0-nolib/ch340/usb_lib.c
Normal file
480
F0-nolib/ch340/usb_lib.c
Normal file
@ -0,0 +1,480 @@
|
|||||||
|
/*
|
||||||
|
* geany_encoding=koi8-r
|
||||||
|
* usb_lib.c
|
||||||
|
*
|
||||||
|
* Copyright 2018 Edward V. Emelianov <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "usb_lib.h"
|
||||||
|
#include <string.h> // memcpy
|
||||||
|
#include "usart.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define EP0DATABUF_SIZE (64)
|
||||||
|
#define DEVICE_DESCRIPTOR_SIZE_BYTE (18)
|
||||||
|
#define DEVICE_QALIFIER_SIZE_BYTE (10)
|
||||||
|
#define STRING_LANG_DESCRIPTOR_SIZE_BYTE (4)
|
||||||
|
|
||||||
|
static usb_LineCoding lineCoding = {115200, 0, 0, 8};
|
||||||
|
static config_pack_t setup_packet;
|
||||||
|
static uint8_t ep0databuf[EP0DATABUF_SIZE];
|
||||||
|
static uint8_t ep0dbuflen = 0;
|
||||||
|
uint8_t setlinecoding = 0;
|
||||||
|
|
||||||
|
usb_LineCoding getLineCoding(){return lineCoding;}
|
||||||
|
|
||||||
|
const uint8_t USB_DeviceDescriptor[] = {
|
||||||
|
DEVICE_DESCRIPTOR_SIZE_BYTE, // bLength
|
||||||
|
0x01, // bDescriptorType - USB_DEVICE_DESC_TYPE
|
||||||
|
0x10, // bcdUSB_L - 1.10
|
||||||
|
0x01, // bcdUSB_H
|
||||||
|
0xff, // bDeviceClass - Vendor Specific Class
|
||||||
|
0x00, // bDeviceSubClass
|
||||||
|
0x00, // bDeviceProtocol
|
||||||
|
0x08, // bMaxPacketSize
|
||||||
|
0x86, // idVendor_L ch340: VID=0x1a86, PID=0x7523
|
||||||
|
0x1a, // idVendor_H
|
||||||
|
0x23, // idProduct_L
|
||||||
|
0x75, // idProduct_H
|
||||||
|
0x36, // bcdDevice_Ver_L
|
||||||
|
0x02, // bcdDevice_Ver_H
|
||||||
|
0x00, // iManufacturer
|
||||||
|
0x02, // iProduct USB2.0-Serial
|
||||||
|
0x00, // iSerialNumber
|
||||||
|
0x01 // bNumConfigurations
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t USB_DeviceQualifierDescriptor[] = {
|
||||||
|
DEVICE_QALIFIER_SIZE_BYTE, //bLength
|
||||||
|
0x06, // bDescriptorType
|
||||||
|
0x10, // bcdUSB_L
|
||||||
|
0x01, // bcdUSB_H
|
||||||
|
0xff, // bDeviceClass
|
||||||
|
0x00, // bDeviceSubClass
|
||||||
|
0x00, // bDeviceProtocol
|
||||||
|
0x08, // bMaxPacketSize0
|
||||||
|
0x01, // bNumConfigurations
|
||||||
|
0x00 // Reserved
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t USB_ConfigDescriptor[] = {
|
||||||
|
/*Configuration Descriptor*/
|
||||||
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
|
0x02, /* bDescriptorType: Configuration */
|
||||||
|
39, /* wTotalLength:no of returned bytes */
|
||||||
|
0x00,
|
||||||
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
|
0x01, /* bConfigurationValue: Configuration value */
|
||||||
|
0x00, /* iConfiguration: Index of string descriptor describing the configuration */
|
||||||
|
0x80, /* bmAttributes - Bus powered */
|
||||||
|
0x32, /* MaxPower 100 mA */
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*Interface Descriptor */
|
||||||
|
0x09, /* bLength: Interface Descriptor size */
|
||||||
|
0x04, /* bDescriptorType: Interface */
|
||||||
|
0x00, /* bInterfaceNumber: Number of Interface */
|
||||||
|
0x00, /* bAlternateSetting: Alternate setting */
|
||||||
|
0x03, /* bNumEndpoints: 3 endpoints used */
|
||||||
|
0xff, /* bInterfaceClass */
|
||||||
|
0x01, /* bInterfaceSubClass */
|
||||||
|
0x02, /* bInterfaceProtocol */
|
||||||
|
0x00, /* iInterface: */
|
||||||
|
///////////////////////////////////////////////////
|
||||||
|
/*Endpoint IN2 Descriptor*/
|
||||||
|
0x07, /* bLength: Endpoint Descriptor size */
|
||||||
|
0x05, /* bDescriptorType: Endpoint */
|
||||||
|
0x82, /* bEndpointAddress IN2 */
|
||||||
|
0x02, /* bmAttributes: Bulk */
|
||||||
|
0x20, /* wMaxPacketSize: 64 */
|
||||||
|
0x00,
|
||||||
|
0x00, /* bInterval: ignore for Bulk transfer */
|
||||||
|
/*Endpoint OUT2 Descriptor*/
|
||||||
|
0x07, /* bLength: Endpoint Descriptor size */
|
||||||
|
0x05, /* bDescriptorType: Endpoint */
|
||||||
|
0x02, /* bEndpointAddress: OUT2 */
|
||||||
|
0x02, /* bmAttributes: Bulk */
|
||||||
|
0x20, /* wMaxPacketSize: */
|
||||||
|
0x00,
|
||||||
|
0x00, /* bInterval: ignore for Bulk transfer */
|
||||||
|
/*Endpoint 1 Descriptor*/
|
||||||
|
0x07, /* bLength: Endpoint Descriptor size */
|
||||||
|
0x05, /* bDescriptorType: Endpoint */
|
||||||
|
0x81, /* bEndpointAddress IN1 */
|
||||||
|
0x03, /* bmAttributes: Interrupt */
|
||||||
|
0x08, /* wMaxPacketSize LO: */
|
||||||
|
0x00, /* wMaxPacketSize HI: */
|
||||||
|
0x01, /* bInterval: */
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t USB_StringLangDescriptor[] = {
|
||||||
|
STRING_LANG_DESCRIPTOR_SIZE_BYTE, // bLength
|
||||||
|
0x03, // bDescriptorType
|
||||||
|
0x09, // wLANGID_L
|
||||||
|
0x04 // wLANGID_H
|
||||||
|
};
|
||||||
|
|
||||||
|
// these descriptors are not used in PL2303 emulator!
|
||||||
|
_USB_STRING_(USB_StringSerialDescriptor, L"0.01")
|
||||||
|
_USB_STRING_(USB_StringManufacturingDescriptor, L"Russia, SAO RAS")
|
||||||
|
_USB_STRING_(USB_StringProdDescriptor, L"TSYS01 sensors controller")
|
||||||
|
|
||||||
|
static usb_dev_t USB_Dev;
|
||||||
|
static ep_t endpoints[MAX_ENDPOINTS];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* default handlers
|
||||||
|
*/
|
||||||
|
// SET_LINE_CODING
|
||||||
|
void WEAK linecoding_handler(__attribute__((unused)) usb_LineCoding *lc){
|
||||||
|
#ifdef EBUG
|
||||||
|
SEND("Want baudrate: "); printu(lc->dwDTERate);
|
||||||
|
SEND(", charFormat: "); printu(lc->bCharFormat);
|
||||||
|
SEND(", parityType: "); printu(lc->bParityType);
|
||||||
|
SEND(", dataBits: "); printu(lc->bDataBits);
|
||||||
|
usart_putchar('\n');
|
||||||
|
#endif
|
||||||
|
setlinecoding = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET_CONTROL_LINE_STATE
|
||||||
|
void WEAK clstate_handler(__attribute__((unused)) uint16_t val){
|
||||||
|
#ifdef EBUG
|
||||||
|
SEND("change state to ");
|
||||||
|
printu(val);
|
||||||
|
usart_putchar('\n');
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// SEND_BREAK
|
||||||
|
void WEAK break_handler(){
|
||||||
|
MSG("Break\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// handler of vendor requests
|
||||||
|
void WEAK vendor_handler(config_pack_t *packet){
|
||||||
|
if(packet->bmRequestType & 0x80){ // read
|
||||||
|
uint8_t c = '?';
|
||||||
|
EP_WriteIRQ(0, &c, 1);
|
||||||
|
}else{ // write ZLP
|
||||||
|
EP_WriteIRQ(0, (uint8_t *)0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
bmRequestType: 76543210
|
||||||
|
7 direction: 0 - host->device, 1 - device->host
|
||||||
|
65 type: 0 - standard, 1 - class, 2 - vendor
|
||||||
|
4..0 getter: 0 - device, 1 - interface, 2 - endpoint, 3 - other
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Endpoint0 (control) handler
|
||||||
|
* @param ep - endpoint state
|
||||||
|
* @return data written to EP0R
|
||||||
|
*/
|
||||||
|
uint16_t EP0_Handler(ep_t ep){
|
||||||
|
uint16_t status = 0; // bus powered
|
||||||
|
uint16_t epstatus = ep.status; // EP0R on input -> return this value after modifications
|
||||||
|
static uint8_t configuration = 0; // reply for GET_CONFIGURATION (==1 if configured)
|
||||||
|
void wr0(const uint8_t *buf, uint16_t size){
|
||||||
|
if(setup_packet.wLength < size) size = setup_packet.wLength;
|
||||||
|
EP_WriteIRQ(0, buf, size);
|
||||||
|
}
|
||||||
|
#ifdef EBUG
|
||||||
|
uint8_t _2wr = 0;
|
||||||
|
#define WRITEDUMP(str) do{MSG(str); _2wr = 1;}while(0)
|
||||||
|
#else
|
||||||
|
#define WRITEDUMP(str)
|
||||||
|
#endif
|
||||||
|
if ((ep.rx_flag) && (ep.setup_flag)){
|
||||||
|
if (setup_packet.bmRequestType == 0x80){ // standard device request (device to host)
|
||||||
|
switch(setup_packet.bRequest){
|
||||||
|
case GET_DESCRIPTOR:
|
||||||
|
switch(setup_packet.wValue){
|
||||||
|
case DEVICE_DESCRIPTOR:
|
||||||
|
wr0(USB_DeviceDescriptor, sizeof(USB_DeviceDescriptor));
|
||||||
|
break;
|
||||||
|
case CONFIGURATION_DESCRIPTOR:
|
||||||
|
wr0(USB_ConfigDescriptor, sizeof(USB_ConfigDescriptor));
|
||||||
|
break;
|
||||||
|
case STRING_LANG_DESCRIPTOR:
|
||||||
|
wr0(USB_StringLangDescriptor, STRING_LANG_DESCRIPTOR_SIZE_BYTE);
|
||||||
|
break;
|
||||||
|
case STRING_MAN_DESCRIPTOR:
|
||||||
|
wr0((const uint8_t *)&USB_StringManufacturingDescriptor, USB_StringManufacturingDescriptor.bLength);
|
||||||
|
break;
|
||||||
|
case STRING_PROD_DESCRIPTOR:
|
||||||
|
wr0((const uint8_t *)&USB_StringProdDescriptor, USB_StringProdDescriptor.bLength);
|
||||||
|
break;
|
||||||
|
case STRING_SN_DESCRIPTOR:
|
||||||
|
wr0((const uint8_t *)&USB_StringSerialDescriptor, USB_StringSerialDescriptor.bLength);
|
||||||
|
break;
|
||||||
|
case DEVICE_QALIFIER_DESCRIPTOR:
|
||||||
|
wr0(USB_DeviceQualifierDescriptor, DEVICE_QALIFIER_SIZE_BYTE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WRITEDUMP("UNK_DES");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GET_STATUS:
|
||||||
|
EP_WriteIRQ(0, (uint8_t *)&status, 2); // send status: Bus Powered
|
||||||
|
break;
|
||||||
|
case GET_CONFIGURATION:
|
||||||
|
WRITEDUMP("GET_CONFIGURATION");
|
||||||
|
EP_WriteIRQ(0, &configuration, 1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WRITEDUMP("80:WR_REQ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
epstatus = SET_NAK_RX(epstatus);
|
||||||
|
epstatus = SET_VALID_TX(epstatus);
|
||||||
|
}else if(setup_packet.bmRequestType == 0x00){ // standard device request (host to device)
|
||||||
|
switch(setup_packet.bRequest){
|
||||||
|
case SET_ADDRESS:
|
||||||
|
// new address will be assigned later - after acknowlegement or request to host
|
||||||
|
USB_Dev.USB_Addr = setup_packet.wValue;
|
||||||
|
break;
|
||||||
|
case SET_CONFIGURATION:
|
||||||
|
// Now device configured
|
||||||
|
USB_Dev.USB_Status = USB_CONFIGURE_STATE;
|
||||||
|
configuration = setup_packet.wValue;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WRITEDUMP("0:WR_REQ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// send ZLP
|
||||||
|
EP_WriteIRQ(0, (uint8_t *)0, 0);
|
||||||
|
epstatus = SET_NAK_RX(epstatus);
|
||||||
|
epstatus = SET_VALID_TX(epstatus);
|
||||||
|
}else if(setup_packet.bmRequestType == 0x02){ // standard endpoint request (host to device)
|
||||||
|
if (setup_packet.bRequest == CLEAR_FEATURE){
|
||||||
|
// send ZLP
|
||||||
|
EP_WriteIRQ(0, (uint8_t *)0, 0);
|
||||||
|
epstatus = SET_NAK_RX(epstatus);
|
||||||
|
epstatus = SET_VALID_TX(epstatus);
|
||||||
|
}else{
|
||||||
|
WRITEDUMP("02:WR_REQ");
|
||||||
|
}
|
||||||
|
}else if((setup_packet.bmRequestType & VENDOR_MASK_REQUEST) == VENDOR_MASK_REQUEST){ // vendor request
|
||||||
|
vendor_handler(&setup_packet);
|
||||||
|
WRITEDUMP("VENDOR");
|
||||||
|
epstatus = SET_NAK_RX(epstatus);
|
||||||
|
epstatus = SET_VALID_TX(epstatus);
|
||||||
|
}else if((setup_packet.bmRequestType & 0x7f) == CONTROL_REQUEST_TYPE){ // control request
|
||||||
|
switch(setup_packet.bRequest){
|
||||||
|
case GET_LINE_CODING:
|
||||||
|
EP_WriteIRQ(0, (uint8_t*)&lineCoding, sizeof(lineCoding));
|
||||||
|
break;
|
||||||
|
case SET_LINE_CODING:
|
||||||
|
break;
|
||||||
|
case SET_CONTROL_LINE_STATE:
|
||||||
|
clstate_handler(setup_packet.wValue);
|
||||||
|
break;
|
||||||
|
case SEND_BREAK:
|
||||||
|
break_handler();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WRITEDUMP("undef control req");
|
||||||
|
}
|
||||||
|
if((setup_packet.bmRequestType & 0x80) == 0) EP_WriteIRQ(0, (uint8_t *)0, 0); // write acknowledgement
|
||||||
|
epstatus = SET_VALID_RX(epstatus);
|
||||||
|
epstatus = SET_VALID_TX(epstatus);
|
||||||
|
}
|
||||||
|
}else if (ep.rx_flag){ // got data over EP0 or host acknowlegement
|
||||||
|
if(ep.rx_cnt){
|
||||||
|
if(setup_packet.bRequest == SET_LINE_CODING){
|
||||||
|
WRITEDUMP("SET_LINE_CODING");
|
||||||
|
linecoding_handler((usb_LineCoding*)ep0databuf);
|
||||||
|
}
|
||||||
|
EP_WriteIRQ(0, (uint8_t *)0, 0);
|
||||||
|
}
|
||||||
|
// Close transaction
|
||||||
|
epstatus = CLEAR_DTOG_RX(epstatus);
|
||||||
|
epstatus = CLEAR_DTOG_TX(epstatus);
|
||||||
|
// wait for new data from host
|
||||||
|
epstatus = SET_VALID_RX(epstatus);
|
||||||
|
epstatus = SET_STALL_TX(epstatus);
|
||||||
|
} else if (ep.tx_flag){ // package transmitted
|
||||||
|
// now we can change address after enumeration
|
||||||
|
if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){
|
||||||
|
USB->DADDR = USB_DADDR_EF | USB_Dev.USB_Addr;
|
||||||
|
// change state to ADRESSED
|
||||||
|
USB_Dev.USB_Status = USB_ADRESSED_STATE;
|
||||||
|
}
|
||||||
|
// end of transaction
|
||||||
|
epstatus = CLEAR_DTOG_RX(epstatus);
|
||||||
|
epstatus = CLEAR_DTOG_TX(epstatus);
|
||||||
|
epstatus = SET_VALID_RX(epstatus);
|
||||||
|
epstatus = SET_VALID_TX(epstatus);
|
||||||
|
}
|
||||||
|
#ifdef EBUG
|
||||||
|
if(_2wr){
|
||||||
|
usart_putchar(' ');
|
||||||
|
if (ep.rx_flag) usart_putchar('r');
|
||||||
|
else usart_putchar('t');
|
||||||
|
printu(setup_packet.wLength);
|
||||||
|
if(ep.setup_flag) usart_putchar('s');
|
||||||
|
usart_putchar(' ');
|
||||||
|
usart_putchar('I');
|
||||||
|
printu(setup_packet.wIndex);
|
||||||
|
usart_putchar('V');
|
||||||
|
printu(setup_packet.wValue);
|
||||||
|
usart_putchar('R');
|
||||||
|
printu(setup_packet.bRequest);
|
||||||
|
usart_putchar('T');
|
||||||
|
printu(setup_packet.bmRequestType);
|
||||||
|
usart_putchar(' ');
|
||||||
|
usart_putchar('0' + ep0dbuflen);
|
||||||
|
usart_putchar(' ');
|
||||||
|
hexdump(ep0databuf, ep0dbuflen);
|
||||||
|
usart_putchar('\n');
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return epstatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Endpoint initialisation, size of input buffer fixed to 64 bytes
|
||||||
|
* @param number - EP num (0...7)
|
||||||
|
* @param type - EP type (EP_TYPE_BULK, EP_TYPE_CONTROL, EP_TYPE_ISO, EP_TYPE_INTERRUPT)
|
||||||
|
* @param addr_tx - transmission buffer address @ USB/CAN buffer
|
||||||
|
* @param addr_rx - reception buffer address @ USB/CAN buffer
|
||||||
|
* @param uint16_t (*func)(ep_t *ep) - EP handler function
|
||||||
|
*/
|
||||||
|
void EP_Init(uint8_t number, uint8_t type, uint16_t addr_tx, uint16_t addr_rx, uint16_t (*func)(ep_t ep)){
|
||||||
|
USB->EPnR[number] = (type << 9) | (number & USB_EPnR_EA);
|
||||||
|
USB->EPnR[number] ^= USB_EPnR_STAT_RX | USB_EPnR_STAT_TX_1;
|
||||||
|
USB_BTABLE->EP[number].USB_ADDR_TX = addr_tx;
|
||||||
|
USB_BTABLE->EP[number].USB_COUNT_TX = 0;
|
||||||
|
USB_BTABLE->EP[number].USB_ADDR_RX = addr_rx;
|
||||||
|
USB_BTABLE->EP[number].USB_COUNT_RX = 0x8400; // buffer size (64 bytes): Table127 of RM: BL_SIZE=1, NUM_BLOCK=1
|
||||||
|
endpoints[number].func = func;
|
||||||
|
endpoints[number].tx_buf = (uint16_t *)(USB_BTABLE_BASE + addr_tx);
|
||||||
|
endpoints[number].rx_buf = (uint8_t *)(USB_BTABLE_BASE + addr_rx);
|
||||||
|
}
|
||||||
|
|
||||||
|
// standard IRQ handler
|
||||||
|
void usb_isr(){
|
||||||
|
uint8_t n;
|
||||||
|
if (USB->ISTR & USB_ISTR_RESET){
|
||||||
|
// Reinit registers
|
||||||
|
USB->CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM;
|
||||||
|
USB->ISTR = 0;
|
||||||
|
// Endpoint 0 - CONTROL
|
||||||
|
EP_Init(0, EP_TYPE_CONTROL, 64, 128, EP0_Handler);
|
||||||
|
// clear address, leave only enable bit
|
||||||
|
USB->DADDR = USB_DADDR_EF;
|
||||||
|
// state is default - wait for enumeration
|
||||||
|
USB_Dev.USB_Status = USB_DEFAULT_STATE;
|
||||||
|
}
|
||||||
|
while(USB->ISTR & USB_ISTR_CTR){
|
||||||
|
// EP number
|
||||||
|
n = USB->ISTR & USB_ISTR_EPID;
|
||||||
|
// copy status register
|
||||||
|
uint16_t epstatus = USB->EPnR[n];
|
||||||
|
// Calculate flags
|
||||||
|
endpoints[n].rx_flag = (epstatus & USB_EPnR_CTR_RX) ? 1 : 0;
|
||||||
|
endpoints[n].setup_flag = (epstatus & USB_EPnR_SETUP) ? 1 : 0;
|
||||||
|
endpoints[n].tx_flag = (epstatus & USB_EPnR_CTR_TX) ? 1 : 0;
|
||||||
|
// copy received bytes amount
|
||||||
|
endpoints[n].rx_cnt = USB_BTABLE->EP[n].USB_COUNT_RX;
|
||||||
|
// check direction
|
||||||
|
if(USB->ISTR & USB_ISTR_DIR){ // OUT interrupt - receive data, CTR_RX==1 (if CTR_TX == 1 - two pending transactions: receive following by transmit)
|
||||||
|
if(n == 0){ // control endpoint
|
||||||
|
if(epstatus & USB_EPnR_SETUP){ // setup packet -> copy data to conf_pack
|
||||||
|
memcpy(&setup_packet, endpoints[0].rx_buf, sizeof(setup_packet));
|
||||||
|
ep0dbuflen = 0;
|
||||||
|
// interrupt handler will be called later
|
||||||
|
}else if(epstatus & USB_EPnR_CTR_RX){ // data packet -> push received data to ep0databuf
|
||||||
|
ep0dbuflen = endpoints[0].rx_cnt;
|
||||||
|
memcpy(ep0databuf, endpoints[0].rx_buf, ep0dbuflen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{ // IN interrupt - transmit data, only CTR_TX == 1
|
||||||
|
// enumeration end could be here (if EP0)
|
||||||
|
}
|
||||||
|
// prepare status field for EP handler
|
||||||
|
endpoints[n].status = epstatus;
|
||||||
|
// call EP handler (even if it will change EPnR, it should return new status)
|
||||||
|
epstatus = endpoints[n].func(endpoints[n]);
|
||||||
|
// keep DTOG state
|
||||||
|
epstatus = KEEP_DTOG_TX(epstatus);
|
||||||
|
epstatus = KEEP_DTOG_RX(epstatus);
|
||||||
|
// clear all RX/TX flags
|
||||||
|
epstatus = CLEAR_CTR_RX(epstatus);
|
||||||
|
epstatus = CLEAR_CTR_TX(epstatus);
|
||||||
|
// refresh EPnR
|
||||||
|
USB->EPnR[n] = epstatus;
|
||||||
|
USB_BTABLE->EP[n].USB_COUNT_RX = 0x8400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write data to EP buffer (called from IRQ handler)
|
||||||
|
* @param number - EP number
|
||||||
|
* @param *buf - array with data
|
||||||
|
* @param size - its size
|
||||||
|
*/
|
||||||
|
void EP_WriteIRQ(uint8_t number, const uint8_t *buf, uint16_t size){
|
||||||
|
uint8_t i;
|
||||||
|
uint16_t N2 = (size + 1) >> 1;
|
||||||
|
// the buffer is 16-bit, so we should copy data as it would be uint16_t
|
||||||
|
uint16_t *buf16 = (uint16_t *)buf;
|
||||||
|
for (i = 0; i < N2; i++){
|
||||||
|
endpoints[number].tx_buf[i] = buf16[i];
|
||||||
|
}
|
||||||
|
USB_BTABLE->EP[number].USB_COUNT_TX = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write data to EP buffer (called outside IRQ handler)
|
||||||
|
* @param number - EP number
|
||||||
|
* @param *buf - array with data
|
||||||
|
* @param size - its size
|
||||||
|
*/
|
||||||
|
void EP_Write(uint8_t number, const uint8_t *buf, uint16_t size){
|
||||||
|
uint16_t status = USB->EPnR[number];
|
||||||
|
EP_WriteIRQ(number, buf, size);
|
||||||
|
status = SET_NAK_RX(status);
|
||||||
|
status = SET_VALID_TX(status);
|
||||||
|
status = KEEP_DTOG_TX(status);
|
||||||
|
status = KEEP_DTOG_RX(status);
|
||||||
|
USB->EPnR[number] = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy data from EP buffer into user buffer area
|
||||||
|
* @param *buf - user array for data
|
||||||
|
* @return amount of data read
|
||||||
|
*/
|
||||||
|
int EP_Read(uint8_t number, uint8_t *buf){
|
||||||
|
int i = endpoints[number].rx_cnt;
|
||||||
|
if(i) memcpy(buf, endpoints[number].rx_buf, i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// USB status
|
||||||
|
uint8_t USB_GetState(){
|
||||||
|
return USB_Dev.USB_Status;
|
||||||
|
}
|
||||||
190
F0-nolib/ch340/usb_lib.h
Normal file
190
F0-nolib/ch340/usb_lib.h
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
/*
|
||||||
|
* geany_encoding=koi8-r
|
||||||
|
* usb_lib.h
|
||||||
|
*
|
||||||
|
* Copyright 2018 Edward V. Emelianov <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef __USB_LIB_H__
|
||||||
|
#define __USB_LIB_H__
|
||||||
|
|
||||||
|
#include <wchar.h>
|
||||||
|
#include "usb_defs.h"
|
||||||
|
|
||||||
|
// Max EP amount (EP0 + other used)
|
||||||
|
#define MAX_ENDPOINTS 4
|
||||||
|
// bRequest, standard; for bmRequestType == 0x80
|
||||||
|
#define GET_STATUS 0x00
|
||||||
|
#define GET_DESCRIPTOR 0x06
|
||||||
|
#define GET_CONFIGURATION 0x08
|
||||||
|
// for bmRequestType == 0
|
||||||
|
#define CLEAR_FEATURE 0x01
|
||||||
|
#define SET_FEATURE 0x03 // unused
|
||||||
|
#define SET_ADDRESS 0x05
|
||||||
|
#define SET_DESCRIPTOR 0x07 // unused
|
||||||
|
#define SET_CONFIGURATION 0x09
|
||||||
|
// for bmRequestType == 0x81, 1 or 0xB2
|
||||||
|
#define GET_INTERFACE 0x0A // unused
|
||||||
|
#define SET_INTERFACE 0x0B // unused
|
||||||
|
#define SYNC_FRAME 0x0C // unused
|
||||||
|
|
||||||
|
// vendor requests
|
||||||
|
#define VENDOR_MASK_REQUEST 0x40
|
||||||
|
#define VENDOR_READ_REQUEST_TYPE 0xc0
|
||||||
|
#define VENDOR_WRITE_REQUEST_TYPE 0x40
|
||||||
|
#define VENDOR_REQUEST 0x01
|
||||||
|
|
||||||
|
#define CONTROL_REQUEST_TYPE 0x21
|
||||||
|
|
||||||
|
// Class-Specific Control Requests
|
||||||
|
#define SEND_ENCAPSULATED_COMMAND 0x00
|
||||||
|
#define GET_ENCAPSULATED_RESPONSE 0x01
|
||||||
|
#define SET_COMM_FEATURE 0x02
|
||||||
|
#define GET_COMM_FEATURE 0x03
|
||||||
|
#define CLEAR_COMM_FEATURE 0x04
|
||||||
|
#define SET_LINE_CODING 0x20
|
||||||
|
#define GET_LINE_CODING 0x21
|
||||||
|
#define SET_CONTROL_LINE_STATE 0x22
|
||||||
|
#define SEND_BREAK 0x23
|
||||||
|
|
||||||
|
// control line states
|
||||||
|
#define CONTROL_DTR 0x01
|
||||||
|
#define CONTROL_RTS 0x02
|
||||||
|
|
||||||
|
// wValue
|
||||||
|
#define DEVICE_DESCRIPTOR 0x100
|
||||||
|
#define CONFIGURATION_DESCRIPTOR 0x200
|
||||||
|
#define STRING_LANG_DESCRIPTOR 0x300
|
||||||
|
#define STRING_MAN_DESCRIPTOR 0x301
|
||||||
|
#define STRING_PROD_DESCRIPTOR 0x302
|
||||||
|
#define STRING_SN_DESCRIPTOR 0x303
|
||||||
|
#define DEVICE_QALIFIER_DESCRIPTOR 0x600
|
||||||
|
|
||||||
|
// EPnR bits manipulation
|
||||||
|
#define CLEAR_DTOG_RX(R) (R & USB_EPnR_DTOG_RX) ? R : (R & (~USB_EPnR_DTOG_RX))
|
||||||
|
#define SET_DTOG_RX(R) (R & USB_EPnR_DTOG_RX) ? (R & (~USB_EPnR_DTOG_RX)) : R
|
||||||
|
#define TOGGLE_DTOG_RX(R) (R | USB_EPnR_DTOG_RX)
|
||||||
|
#define KEEP_DTOG_RX(R) (R & (~USB_EPnR_DTOG_RX))
|
||||||
|
#define CLEAR_DTOG_TX(R) (R & USB_EPnR_DTOG_TX) ? R : (R & (~USB_EPnR_DTOG_TX))
|
||||||
|
#define SET_DTOG_TX(R) (R & USB_EPnR_DTOG_TX) ? (R & (~USB_EPnR_DTOG_TX)) : R
|
||||||
|
#define TOGGLE_DTOG_TX(R) (R | USB_EPnR_DTOG_TX)
|
||||||
|
#define KEEP_DTOG_TX(R) (R & (~USB_EPnR_DTOG_TX))
|
||||||
|
#define SET_VALID_RX(R) ((R & USB_EPnR_STAT_RX) ^ USB_EPnR_STAT_RX) | (R & (~USB_EPnR_STAT_RX))
|
||||||
|
#define SET_NAK_RX(R) ((R & USB_EPnR_STAT_RX) ^ USB_EPnR_STAT_RX_1) | (R & (~USB_EPnR_STAT_RX))
|
||||||
|
#define SET_STALL_RX(R) ((R & USB_EPnR_STAT_RX) ^ USB_EPnR_STAT_RX_0) | (R & (~USB_EPnR_STAT_RX))
|
||||||
|
#define KEEP_STAT_RX(R) (R & (~USB_EPnR_STAT_RX))
|
||||||
|
#define SET_VALID_TX(R) ((R & USB_EPnR_STAT_TX) ^ USB_EPnR_STAT_TX) | (R & (~USB_EPnR_STAT_TX))
|
||||||
|
#define SET_NAK_TX(R) ((R & USB_EPnR_STAT_TX) ^ USB_EPnR_STAT_TX_1) | (R & (~USB_EPnR_STAT_TX))
|
||||||
|
#define SET_STALL_TX(R) ((R & USB_EPnR_STAT_TX) ^ USB_EPnR_STAT_TX_0) | (R & (~USB_EPnR_STAT_TX))
|
||||||
|
#define KEEP_STAT_TX(R) (R & (~USB_EPnR_STAT_TX))
|
||||||
|
#define CLEAR_CTR_RX(R) (R & (~USB_EPnR_CTR_RX))
|
||||||
|
#define CLEAR_CTR_TX(R) (R & (~USB_EPnR_CTR_TX))
|
||||||
|
#define CLEAR_CTR_RX_TX(R) (R & (~(USB_EPnR_CTR_TX | USB_EPnR_CTR_RX)))
|
||||||
|
|
||||||
|
// USB state: uninitialized, addressed, ready for use
|
||||||
|
#define USB_DEFAULT_STATE 0
|
||||||
|
#define USB_ADRESSED_STATE 1
|
||||||
|
#define USB_CONFIGURE_STATE 2
|
||||||
|
|
||||||
|
// EP types
|
||||||
|
#define EP_TYPE_BULK 0x00
|
||||||
|
#define EP_TYPE_CONTROL 0x01
|
||||||
|
#define EP_TYPE_ISO 0x02
|
||||||
|
#define EP_TYPE_INTERRUPT 0x03
|
||||||
|
|
||||||
|
#define _USB_STRING_(name, str) \
|
||||||
|
const struct name \
|
||||||
|
{ \
|
||||||
|
uint8_t bLength; \
|
||||||
|
uint8_t bDescriptorType; \
|
||||||
|
wchar_t bString[(sizeof(str) - 2) / 2]; \
|
||||||
|
\
|
||||||
|
} \
|
||||||
|
name = {sizeof(name), 0x03, str};
|
||||||
|
|
||||||
|
// EP0 configuration packet
|
||||||
|
typedef struct {
|
||||||
|
uint8_t bmRequestType;
|
||||||
|
uint8_t bRequest;
|
||||||
|
uint16_t wValue;
|
||||||
|
uint16_t wIndex;
|
||||||
|
uint16_t wLength;
|
||||||
|
} config_pack_t;
|
||||||
|
|
||||||
|
// endpoints state
|
||||||
|
typedef struct __ep_t{
|
||||||
|
uint16_t *tx_buf;
|
||||||
|
uint8_t *rx_buf;
|
||||||
|
uint16_t (*func)();
|
||||||
|
uint16_t status;
|
||||||
|
unsigned rx_cnt : 10;
|
||||||
|
unsigned tx_flag : 1;
|
||||||
|
unsigned rx_flag : 1;
|
||||||
|
unsigned setup_flag : 1;
|
||||||
|
} ep_t;
|
||||||
|
|
||||||
|
// USB status & its address
|
||||||
|
typedef struct {
|
||||||
|
uint8_t USB_Status;
|
||||||
|
uint16_t USB_Addr;
|
||||||
|
}usb_dev_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t dwDTERate;
|
||||||
|
uint8_t bCharFormat;
|
||||||
|
#define USB_CDC_1_STOP_BITS 0
|
||||||
|
#define USB_CDC_1_5_STOP_BITS 1
|
||||||
|
#define USB_CDC_2_STOP_BITS 2
|
||||||
|
uint8_t bParityType;
|
||||||
|
#define USB_CDC_NO_PARITY 0
|
||||||
|
#define USB_CDC_ODD_PARITY 1
|
||||||
|
#define USB_CDC_EVEN_PARITY 2
|
||||||
|
#define USB_CDC_MARK_PARITY 3
|
||||||
|
#define USB_CDC_SPACE_PARITY 4
|
||||||
|
uint8_t bDataBits;
|
||||||
|
} __attribute__ ((packed)) usb_LineCoding;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t bmRequestType;
|
||||||
|
uint8_t bNotificationType;
|
||||||
|
uint16_t wValue;
|
||||||
|
uint16_t wIndex;
|
||||||
|
uint16_t wLength;
|
||||||
|
} __attribute__ ((packed)) usb_cdc_notification;
|
||||||
|
|
||||||
|
extern uint8_t setlinecoding;
|
||||||
|
#define SETLINECODING() (setlinecoding)
|
||||||
|
#define CLRLINECODING() do{setlinecoding = 0;}while(0)
|
||||||
|
|
||||||
|
void USB_Init();
|
||||||
|
uint8_t USB_GetState();
|
||||||
|
void EP_Init(uint8_t number, uint8_t type, uint16_t addr_tx, uint16_t addr_rx, uint16_t (*func)(ep_t ep));
|
||||||
|
void EP_WriteIRQ(uint8_t number, const uint8_t *buf, uint16_t size);
|
||||||
|
void EP_Write(uint8_t number, const uint8_t *buf, uint16_t size);
|
||||||
|
int EP_Read(uint8_t number, uint8_t *buf);
|
||||||
|
usb_LineCoding getLineCoding();
|
||||||
|
|
||||||
|
|
||||||
|
void WEAK linecoding_handler(usb_LineCoding *lc);
|
||||||
|
void WEAK clstate_handler(uint16_t val);
|
||||||
|
void WEAK break_handler();
|
||||||
|
void WEAK vendor_handler(config_pack_t *packet);
|
||||||
|
|
||||||
|
#endif // __USB_LIB_H__
|
||||||
Binary file not shown.
@ -48,7 +48,7 @@ STARTUP = $(OBJDIR)/startup.o
|
|||||||
OBJS += $(STARTUP)
|
OBJS += $(STARTUP)
|
||||||
DEPS := $(OBJS:.o=.d)
|
DEPS := $(OBJS:.o=.d)
|
||||||
|
|
||||||
INC_DIR ?= ../../inc
|
INC_DIR ?= ../inc
|
||||||
|
|
||||||
INCLUDE := -I$(INC_DIR)/F0 -I$(INC_DIR)/cm
|
INCLUDE := -I$(INC_DIR)/F0 -I$(INC_DIR)/cm
|
||||||
LIB_DIR := $(INC_DIR)/ld
|
LIB_DIR := $(INC_DIR)/ld
|
||||||
|
|||||||
@ -230,18 +230,25 @@ CAN_status can_send(uint8_t *msg, uint8_t len, uint16_t target_id){
|
|||||||
switch(len){
|
switch(len){
|
||||||
case 8:
|
case 8:
|
||||||
hb |= (uint32_t)msg[7] << 24;
|
hb |= (uint32_t)msg[7] << 24;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 7:
|
case 7:
|
||||||
hb |= (uint32_t)msg[6] << 16;
|
hb |= (uint32_t)msg[6] << 16;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 6:
|
case 6:
|
||||||
hb |= (uint32_t)msg[5] << 8;
|
hb |= (uint32_t)msg[5] << 8;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 5:
|
case 5:
|
||||||
hb |= (uint32_t)msg[4];
|
hb |= (uint32_t)msg[4];
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 4:
|
case 4:
|
||||||
lb |= (uint32_t)msg[3] << 24;
|
lb |= (uint32_t)msg[3] << 24;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 3:
|
case 3:
|
||||||
lb |= (uint32_t)msg[2] << 16;
|
lb |= (uint32_t)msg[2] << 16;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 2:
|
case 2:
|
||||||
lb |= (uint32_t)msg[1] << 8;
|
lb |= (uint32_t)msg[1] << 8;
|
||||||
|
__attribute__((fallthrough));
|
||||||
default:
|
default:
|
||||||
lb |= (uint32_t)msg[0];
|
lb |= (uint32_t)msg[0];
|
||||||
}
|
}
|
||||||
@ -292,18 +299,25 @@ static void can_process_fifo(uint8_t fifo_num){
|
|||||||
switch(len){
|
switch(len){
|
||||||
case 8:
|
case 8:
|
||||||
dat[7] = hb>>24;
|
dat[7] = hb>>24;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 7:
|
case 7:
|
||||||
dat[6] = (hb>>16) & 0xff;
|
dat[6] = (hb>>16) & 0xff;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 6:
|
case 6:
|
||||||
dat[5] = (hb>>8) & 0xff;
|
dat[5] = (hb>>8) & 0xff;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 5:
|
case 5:
|
||||||
dat[4] = hb & 0xff;
|
dat[4] = hb & 0xff;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 4:
|
case 4:
|
||||||
dat[3] = lb>>24;
|
dat[3] = lb>>24;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 3:
|
case 3:
|
||||||
dat[2] = (lb>>16) & 0xff;
|
dat[2] = (lb>>16) & 0xff;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 2:
|
case 2:
|
||||||
dat[1] = (lb>>8) & 0xff;
|
dat[1] = (lb>>8) & 0xff;
|
||||||
|
__attribute__((fallthrough));
|
||||||
case 1:
|
case 1:
|
||||||
dat[0] = lb & 0xff;
|
dat[0] = lb & 0xff;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
47
F1-nolib/inc/Fx/common_macros.h
Normal file
47
F1-nolib/inc/Fx/common_macros.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* common_macros.h - common usable things
|
||||||
|
*
|
||||||
|
* Copyright 2018 Edward V. Emelianoff <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#ifndef __COMMON_MACROS_H__
|
||||||
|
#define __COMMON_MACROS_H__
|
||||||
|
|
||||||
|
#ifndef TRUE_INLINE
|
||||||
|
#define TRUE_INLINE __attribute__((always_inline)) static inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define NULL (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// some good things from CMSIS
|
||||||
|
#define nop() __NOP()
|
||||||
|
|
||||||
|
#define pin_toggle(gpioport, gpios) do{ \
|
||||||
|
register uint32_t __port = gpioport->ODR; \
|
||||||
|
gpioport->BSRR = ((__port & gpios) << 16) | (~__port & gpios);}while(0)
|
||||||
|
|
||||||
|
#define pin_set(gpioport, gpios) do{gpioport->BSRR = gpios;}while(0)
|
||||||
|
#define pin_clear(gpioport, gpios) do{gpioport->BSRR = (gpios << 16);}while(0)
|
||||||
|
#define pin_read(gpioport, gpios) (gpioport->IDR & gpios ? 1 : 0)
|
||||||
|
#define pin_write(gpioport, gpios) do{gpioport->ODR = gpios;}while(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __COMMON_MACROS_H__
|
||||||
213
F1-nolib/inc/Fx/stm32f0.h
Normal file
213
F1-nolib/inc/Fx/stm32f0.h
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
/*
|
||||||
|
* stm32f0.h
|
||||||
|
*
|
||||||
|
* Copyright 2017 Edward V. Emelianoff <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#ifndef __STM32F0_H__
|
||||||
|
#define __STM32F0_H__
|
||||||
|
|
||||||
|
#include "stm32f0xx.h"
|
||||||
|
#include "common_macros.h"
|
||||||
|
|
||||||
|
|
||||||
|
/************************* RCC *************************/
|
||||||
|
// reset clocking registers
|
||||||
|
TRUE_INLINE void sysreset(void){
|
||||||
|
/* Reset the RCC clock configuration to the default reset state ------------*/
|
||||||
|
/* Set HSION bit */
|
||||||
|
RCC->CR |= (uint32_t)0x00000001;
|
||||||
|
#if defined (STM32F051x8) || defined (STM32F058x8)
|
||||||
|
/* Reset SW[1:0], HPRE[3:0], PPRE[2:0], ADCPRE and MCOSEL[2:0] bits */
|
||||||
|
RCC->CFGR &= (uint32_t)0xF8FFB80C;
|
||||||
|
#else
|
||||||
|
/* Reset SW[1:0], HPRE[3:0], PPRE[2:0], ADCPRE, MCOSEL[2:0], MCOPRE[2:0] and PLLNODIV bits */
|
||||||
|
RCC->CFGR &= (uint32_t)0x08FFB80C;
|
||||||
|
#endif /* STM32F051x8 or STM32F058x8 */
|
||||||
|
/* Reset HSEON, CSSON and PLLON bits */
|
||||||
|
RCC->CR &= (uint32_t)0xFEF6FFFF;
|
||||||
|
/* Reset HSEBYP bit */
|
||||||
|
RCC->CR &= (uint32_t)0xFFFBFFFF;
|
||||||
|
/* Reset PLLSRC, PLLXTPRE and PLLMUL[3:0] bits */
|
||||||
|
RCC->CFGR &= (uint32_t)0xFFC0FFFF;
|
||||||
|
/* Reset PREDIV[3:0] bits */
|
||||||
|
RCC->CFGR2 &= (uint32_t)0xFFFFFFF0;
|
||||||
|
#if defined (STM32F072xB) || defined (STM32F078xB)
|
||||||
|
/* Reset USART2SW[1:0], USART1SW[1:0], I2C1SW, CECSW, USBSW and ADCSW bits */
|
||||||
|
RCC->CFGR3 &= (uint32_t)0xFFFCFE2C;
|
||||||
|
#elif defined (STM32F071xB)
|
||||||
|
/* Reset USART2SW[1:0], USART1SW[1:0], I2C1SW, CECSW and ADCSW bits */
|
||||||
|
RCC->CFGR3 &= (uint32_t)0xFFFFCEAC;
|
||||||
|
#elif defined (STM32F091xC) || defined (STM32F098xx)
|
||||||
|
/* Reset USART3SW[1:0], USART2SW[1:0], USART1SW[1:0], I2C1SW, CECSW and ADCSW bits */
|
||||||
|
RCC->CFGR3 &= (uint32_t)0xFFF0FEAC;
|
||||||
|
#elif defined (STM32F030x4) || defined (STM32F030x6) || defined (STM32F030x8) || defined (STM32F031x6) || defined (STM32F038xx) || defined (STM32F030xC)
|
||||||
|
/* Reset USART1SW[1:0], I2C1SW and ADCSW bits */
|
||||||
|
RCC->CFGR3 &= (uint32_t)0xFFFFFEEC;
|
||||||
|
#elif defined (STM32F051x8) || defined (STM32F058xx)
|
||||||
|
/* Reset USART1SW[1:0], I2C1SW, CECSW and ADCSW bits */
|
||||||
|
RCC->CFGR3 &= (uint32_t)0xFFFFFEAC;
|
||||||
|
#elif defined (STM32F042x6) || defined (STM32F048xx)
|
||||||
|
/* Reset USART1SW[1:0], I2C1SW, CECSW, USBSW and ADCSW bits */
|
||||||
|
RCC->CFGR3 &= (uint32_t)0xFFFFFE2C;
|
||||||
|
#elif defined (STM32F070x6) || defined (STM32F070xB)
|
||||||
|
/* Reset USART1SW[1:0], I2C1SW, USBSW and ADCSW bits */
|
||||||
|
RCC->CFGR3 &= (uint32_t)0xFFFFFE6C;
|
||||||
|
/* Set default USB clock to PLLCLK, since there is no HSI48 */
|
||||||
|
RCC->CFGR3 |= (uint32_t)0x00000080;
|
||||||
|
#else
|
||||||
|
#error "No target selected"
|
||||||
|
#endif
|
||||||
|
/* Disable all interrupts */
|
||||||
|
RCC->CIR = 0x00000000;
|
||||||
|
/* Reset HSI14 bit */
|
||||||
|
RCC->CR2 &= (uint32_t)0xFFFFFFFE;
|
||||||
|
// Enable Prefetch Buffer and set Flash Latency
|
||||||
|
FLASH->ACR = FLASH_ACR_PRFTBE | FLASH_ACR_LATENCY;
|
||||||
|
/* HCLK = SYSCLK */
|
||||||
|
RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
|
||||||
|
/* PCLK = HCLK */
|
||||||
|
RCC->CFGR |= RCC_CFGR_PPRE_DIV1;
|
||||||
|
/* PLL configuration = (HSI/2) * 12 = ~48 MHz */
|
||||||
|
RCC->CFGR &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL);
|
||||||
|
RCC->CFGR |= RCC_CFGR_PLLMUL12;
|
||||||
|
/* Enable PLL */
|
||||||
|
RCC->CR |= RCC_CR_PLLON;
|
||||||
|
/* Wait till PLL is ready */
|
||||||
|
while((RCC->CR & RCC_CR_PLLRDY) == 0){}
|
||||||
|
/* Select PLL as system clock source */
|
||||||
|
RCC->CFGR &= ~RCC_CFGR_SW;
|
||||||
|
RCC->CFGR |= RCC_CFGR_SW_PLL;
|
||||||
|
/* Wait till PLL is used as system clock source */
|
||||||
|
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL){}
|
||||||
|
}
|
||||||
|
|
||||||
|
TRUE_INLINE void StartHSE(){
|
||||||
|
// disable PLL
|
||||||
|
RCC->CR &= ~RCC_CR_PLLON;
|
||||||
|
RCC->CR |= RCC_CR_HSEON;
|
||||||
|
while ((RCC->CIR & RCC_CIR_HSERDYF) != 0);
|
||||||
|
RCC->CIR |= RCC_CIR_HSERDYC; // clear rdy flag
|
||||||
|
/* PLL configuration = (HSE) * 12 = ~48 MHz */
|
||||||
|
RCC->CFGR &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL);
|
||||||
|
RCC->CFGR |= RCC_CFGR_PLLSRC_HSE_PREDIV | RCC_CFGR_PLLMUL12;
|
||||||
|
RCC->CR |= RCC_CR_PLLON;
|
||||||
|
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)RCC_CFGR_SWS_PLL){}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined (STM32F030x4) && !defined (STM32F030x6) && !defined (STM32F030x8) && !defined (STM32F031x6) && !defined (STM32F038xx) && !defined (STM32F030xC)
|
||||||
|
TRUE_INLINE void StartHSI48(){
|
||||||
|
// disable PLL
|
||||||
|
RCC->CR &= ~RCC_CR_PLLON;
|
||||||
|
RCC->CR2 &= RCC_CR2_HSI48ON; // turn on HSI48
|
||||||
|
while((RCC->CR2 & RCC_CR2_HSI48RDY) == 0);
|
||||||
|
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL));
|
||||||
|
// HSI48/2 * 2 = HSI48
|
||||||
|
RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSI48_PREDIV | RCC_CFGR_PLLMUL2);
|
||||||
|
RCC->CR |= RCC_CR_PLLON;
|
||||||
|
// select HSI48 as system clock source
|
||||||
|
RCC->CFGR &= ~RCC_CFGR_SW;
|
||||||
|
RCC->CFGR |= RCC_CFGR_SW_HSI48;
|
||||||
|
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)RCC_CFGR_SWS_HSI48){}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/************************* GPIO *************************/
|
||||||
|
|
||||||
|
/******************* Bit definition for GPIO_MODER register *****************/
|
||||||
|
// _AI - analog inpt, _O - general output, _AF - alternate function
|
||||||
|
#define GPIO_MODER_MODER0_AI ((uint32_t)0x00000003)
|
||||||
|
#define GPIO_MODER_MODER0_O ((uint32_t)0x00000001)
|
||||||
|
#define GPIO_MODER_MODER0_AF ((uint32_t)0x00000002)
|
||||||
|
#define GPIO_MODER_MODER1_AI ((uint32_t)0x0000000C)
|
||||||
|
#define GPIO_MODER_MODER1_O ((uint32_t)0x00000004)
|
||||||
|
#define GPIO_MODER_MODER1_AF ((uint32_t)0x00000008)
|
||||||
|
#define GPIO_MODER_MODER2_AI ((uint32_t)0x00000030)
|
||||||
|
#define GPIO_MODER_MODER2_O ((uint32_t)0x00000010)
|
||||||
|
#define GPIO_MODER_MODER2_AF ((uint32_t)0x00000020)
|
||||||
|
#define GPIO_MODER_MODER3_AI ((uint32_t)0x000000C0)
|
||||||
|
#define GPIO_MODER_MODER3_O ((uint32_t)0x00000040)
|
||||||
|
#define GPIO_MODER_MODER3_AF ((uint32_t)0x00000080)
|
||||||
|
#define GPIO_MODER_MODER4_AI ((uint32_t)0x00000300)
|
||||||
|
#define GPIO_MODER_MODER4_O ((uint32_t)0x00000100)
|
||||||
|
#define GPIO_MODER_MODER4_AF ((uint32_t)0x00000200)
|
||||||
|
#define GPIO_MODER_MODER5_AI ((uint32_t)0x00000C00)
|
||||||
|
#define GPIO_MODER_MODER5_O ((uint32_t)0x00000400)
|
||||||
|
#define GPIO_MODER_MODER5_AF ((uint32_t)0x00000800)
|
||||||
|
#define GPIO_MODER_MODER6_AI ((uint32_t)0x00003000)
|
||||||
|
#define GPIO_MODER_MODER6_O ((uint32_t)0x00001000)
|
||||||
|
#define GPIO_MODER_MODER6_AF ((uint32_t)0x00002000)
|
||||||
|
#define GPIO_MODER_MODER7_AI ((uint32_t)0x0000C000)
|
||||||
|
#define GPIO_MODER_MODER7_O ((uint32_t)0x00004000)
|
||||||
|
#define GPIO_MODER_MODER7_AF ((uint32_t)0x00008000)
|
||||||
|
#define GPIO_MODER_MODER8_AI ((uint32_t)0x00030000)
|
||||||
|
#define GPIO_MODER_MODER8_O ((uint32_t)0x00010000)
|
||||||
|
#define GPIO_MODER_MODER8_AF ((uint32_t)0x00020000)
|
||||||
|
#define GPIO_MODER_MODER9_AI ((uint32_t)0x000C0000)
|
||||||
|
#define GPIO_MODER_MODER9_O ((uint32_t)0x00040000)
|
||||||
|
#define GPIO_MODER_MODER9_AF ((uint32_t)0x00080000)
|
||||||
|
#define GPIO_MODER_MODER10_AI ((uint32_t)0x00300000)
|
||||||
|
#define GPIO_MODER_MODER10_O ((uint32_t)0x00100000)
|
||||||
|
#define GPIO_MODER_MODER10_AF ((uint32_t)0x00200000)
|
||||||
|
#define GPIO_MODER_MODER11_AI ((uint32_t)0x00C00000)
|
||||||
|
#define GPIO_MODER_MODER11_O ((uint32_t)0x00400000)
|
||||||
|
#define GPIO_MODER_MODER11_AF ((uint32_t)0x00800000)
|
||||||
|
#define GPIO_MODER_MODER12_AI ((uint32_t)0x03000000)
|
||||||
|
#define GPIO_MODER_MODER12_O ((uint32_t)0x01000000)
|
||||||
|
#define GPIO_MODER_MODER12_AF ((uint32_t)0x02000000)
|
||||||
|
#define GPIO_MODER_MODER13_AI ((uint32_t)0x0C000000)
|
||||||
|
#define GPIO_MODER_MODER13_O ((uint32_t)0x04000000)
|
||||||
|
#define GPIO_MODER_MODER13_AF ((uint32_t)0x08000000)
|
||||||
|
#define GPIO_MODER_MODER14_AI ((uint32_t)0x30000000)
|
||||||
|
#define GPIO_MODER_MODER14_O ((uint32_t)0x10000000)
|
||||||
|
#define GPIO_MODER_MODER14_AF ((uint32_t)0x20000000)
|
||||||
|
#define GPIO_MODER_MODER15_AI ((uint32_t)0xC0000000)
|
||||||
|
#define GPIO_MODER_MODER15_O ((uint32_t)0x40000000)
|
||||||
|
#define GPIO_MODER_MODER15_AF ((uint32_t)0x80000000)
|
||||||
|
|
||||||
|
|
||||||
|
/************************* ADC *************************/
|
||||||
|
/* inner termometer calibration values
|
||||||
|
* Temp = (V30 - Vsense)/Avg_Slope + 30
|
||||||
|
* Avg_Slope = (V30 - V110) / (110 - 30)
|
||||||
|
*/
|
||||||
|
#define TEMP110_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7C2))
|
||||||
|
#define TEMP30_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7B8))
|
||||||
|
// VDDA_Actual = 3.3V * VREFINT_CAL / average vref value
|
||||||
|
#define VREFINT_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7BA))
|
||||||
|
#define VDD_CALIB ((uint16_t) (330))
|
||||||
|
#define VDD_APPLI ((uint16_t) (300))
|
||||||
|
|
||||||
|
/************************* USART *************************/
|
||||||
|
|
||||||
|
#define USART_CR2_ADD_SHIFT 24
|
||||||
|
// set address/character match value
|
||||||
|
#define USART_CR2_ADD_VAL(x) ((x) << USART_CR2_ADD_SHIFT)
|
||||||
|
|
||||||
|
/************************* IWDG *************************/
|
||||||
|
#define IWDG_REFRESH (uint32_t)(0x0000AAAA)
|
||||||
|
#define IWDG_WRITE_ACCESS (uint32_t)(0x00005555)
|
||||||
|
#define IWDG_START (uint32_t)(0x0000CCCC)
|
||||||
|
|
||||||
|
|
||||||
|
//#define do{}while(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __STM32F0_H__
|
||||||
3161
F1-nolib/inc/Fx/stm32f030x6.h
Normal file
3161
F1-nolib/inc/Fx/stm32f030x6.h
Normal file
File diff suppressed because it is too large
Load Diff
3213
F1-nolib/inc/Fx/stm32f030x8.h
Normal file
3213
F1-nolib/inc/Fx/stm32f030x8.h
Normal file
File diff suppressed because it is too large
Load Diff
3338
F1-nolib/inc/Fx/stm32f030xc.h
Normal file
3338
F1-nolib/inc/Fx/stm32f030xc.h
Normal file
File diff suppressed because it is too large
Load Diff
3252
F1-nolib/inc/Fx/stm32f031x6.h
Normal file
3252
F1-nolib/inc/Fx/stm32f031x6.h
Normal file
File diff suppressed because it is too large
Load Diff
3230
F1-nolib/inc/Fx/stm32f038xx.h
Normal file
3230
F1-nolib/inc/Fx/stm32f038xx.h
Normal file
File diff suppressed because it is too large
Load Diff
5274
F1-nolib/inc/Fx/stm32f042x6.h
Normal file
5274
F1-nolib/inc/Fx/stm32f042x6.h
Normal file
File diff suppressed because it is too large
Load Diff
5253
F1-nolib/inc/Fx/stm32f048xx.h
Normal file
5253
F1-nolib/inc/Fx/stm32f048xx.h
Normal file
File diff suppressed because it is too large
Load Diff
3807
F1-nolib/inc/Fx/stm32f051x8.h
Normal file
3807
F1-nolib/inc/Fx/stm32f051x8.h
Normal file
File diff suppressed because it is too large
Load Diff
3784
F1-nolib/inc/Fx/stm32f058xx.h
Normal file
3784
F1-nolib/inc/Fx/stm32f058xx.h
Normal file
File diff suppressed because it is too large
Load Diff
3342
F1-nolib/inc/Fx/stm32f070x6.h
Normal file
3342
F1-nolib/inc/Fx/stm32f070x6.h
Normal file
File diff suppressed because it is too large
Load Diff
3419
F1-nolib/inc/Fx/stm32f070xb.h
Normal file
3419
F1-nolib/inc/Fx/stm32f070xb.h
Normal file
File diff suppressed because it is too large
Load Diff
4065
F1-nolib/inc/Fx/stm32f071xb.h
Normal file
4065
F1-nolib/inc/Fx/stm32f071xb.h
Normal file
File diff suppressed because it is too large
Load Diff
5575
F1-nolib/inc/Fx/stm32f072xb.h
Normal file
5575
F1-nolib/inc/Fx/stm32f072xb.h
Normal file
File diff suppressed because it is too large
Load Diff
5554
F1-nolib/inc/Fx/stm32f078xx.h
Normal file
5554
F1-nolib/inc/Fx/stm32f078xx.h
Normal file
File diff suppressed because it is too large
Load Diff
5710
F1-nolib/inc/Fx/stm32f091xc.h
Normal file
5710
F1-nolib/inc/Fx/stm32f091xc.h
Normal file
File diff suppressed because it is too large
Load Diff
5667
F1-nolib/inc/Fx/stm32f098xx.h
Normal file
5667
F1-nolib/inc/Fx/stm32f098xx.h
Normal file
File diff suppressed because it is too large
Load Diff
202
F1-nolib/inc/Fx/stm32f0xx.h
Normal file
202
F1-nolib/inc/Fx/stm32f0xx.h
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f0xx.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @version V2.2.0
|
||||||
|
* @date 05-December-2014
|
||||||
|
* @brief CMSIS STM32F0xx Device Peripheral Access Layer Header File.
|
||||||
|
*
|
||||||
|
* The file is the unique include file that the application programmer
|
||||||
|
* is using in the C source code, usually in main.c. This file contains:
|
||||||
|
* - Configuration section that allows to select:
|
||||||
|
* - The STM32F0xx device used in the target application
|
||||||
|
* - To use or not the peripheral's drivers in application code(i.e.
|
||||||
|
* code will be based on direct access to peripheral's registers
|
||||||
|
* rather than drivers API), this option is controlled by
|
||||||
|
* "#define USE_HAL_DRIVER"
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup CMSIS
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup stm32f0xx
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __STM32F0xx_H
|
||||||
|
#define __STM32F0xx_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/** @addtogroup Library_configuration_section
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined (STM32F030x4) && !defined (STM32F030x6) && !defined (STM32F030x8) && \
|
||||||
|
!defined (STM32F031x6) && !defined (STM32F038xx) && \
|
||||||
|
!defined (STM32F042x6) && !defined (STM32F048xx) && !defined (STM32F070x6) && \
|
||||||
|
!defined (STM32F051x8) && !defined (STM32F058xx) && \
|
||||||
|
!defined (STM32F071xB) && !defined (STM32F072xB) && !defined (STM32F078xx) && !defined (STM32F070xB) && \
|
||||||
|
!defined (STM32F091xC) && !defined (STM32F098xx) && !defined (STM32F030xC)
|
||||||
|
#error "Define STM32 family, for example -DSTM32F042x6"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief CMSIS Device version number V2.2.0
|
||||||
|
*/
|
||||||
|
#define __STM32F0xx_CMSIS_DEVICE_VERSION_MAIN (0x02) /*!< [31:24] main version */
|
||||||
|
#define __STM32F0xx_CMSIS_DEVICE_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
|
||||||
|
#define __STM32F0xx_CMSIS_DEVICE_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
|
||||||
|
#define __STM32F0xx_CMSIS_DEVICE_VERSION_RC (0x00) /*!< [7:0] release candidate */
|
||||||
|
#define __STM32F0xx_CMSIS_DEVICE_VERSION ((__CMSIS_DEVICE_VERSION_MAIN << 24)\
|
||||||
|
|(__CMSIS_DEVICE_HAL_VERSION_SUB1 << 16)\
|
||||||
|
|(__CMSIS_DEVICE_HAL_VERSION_SUB2 << 8 )\
|
||||||
|
|(__CMSIS_DEVICE_HAL_VERSION_RC))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup Device_Included
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
// arch-dependent defines
|
||||||
|
#if defined(STM32F030x4)
|
||||||
|
#include "stm32f030x6.h"
|
||||||
|
#elif defined(STM32F030x6)
|
||||||
|
#include "stm32f030x6.h"
|
||||||
|
#elif defined(STM32F030x8)
|
||||||
|
#include "stm32f030x8.h"
|
||||||
|
#elif defined(STM32F031x6)
|
||||||
|
#include "stm32f031x6.h"
|
||||||
|
#elif defined(STM32F038xx)
|
||||||
|
#include "stm32f038xx.h"
|
||||||
|
#elif defined(STM32F042x6)
|
||||||
|
#include "stm32f042x6.h"
|
||||||
|
#elif defined(STM32F048xx)
|
||||||
|
#include "stm32f048xx.h"
|
||||||
|
#elif defined(STM32F051x8)
|
||||||
|
#include "stm32f051x8.h"
|
||||||
|
#elif defined(STM32F058xx)
|
||||||
|
#include "stm32f058xx.h"
|
||||||
|
#elif defined(STM32F070x6)
|
||||||
|
#include "stm32f070x6.h"
|
||||||
|
#elif defined(STM32F070xB)
|
||||||
|
#include "stm32f070xb.h"
|
||||||
|
#elif defined(STM32F071xB)
|
||||||
|
#include "stm32f071xb.h"
|
||||||
|
#elif defined(STM32F072xB)
|
||||||
|
#include "stm32f072xb.h"
|
||||||
|
#elif defined(STM32F078xx)
|
||||||
|
#include "stm32f078xx.h"
|
||||||
|
#elif defined(STM32F091xC)
|
||||||
|
#include "stm32f091xc.h"
|
||||||
|
#elif defined(STM32F098xx)
|
||||||
|
#include "stm32f098xx.h"
|
||||||
|
#elif defined(STM32F030xC)
|
||||||
|
#include "stm32f030xc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup Exported_types
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
RESET = 0,
|
||||||
|
SET = !RESET
|
||||||
|
} FlagStatus, ITStatus;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
DISABLE = 0,
|
||||||
|
ENABLE = !DISABLE
|
||||||
|
} FunctionalState;
|
||||||
|
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
ERROR = 0,
|
||||||
|
SUCCESS = !ERROR
|
||||||
|
} ErrorStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** @addtogroup Exported_macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SET_BIT(REG, BIT) ((REG) |= (BIT))
|
||||||
|
|
||||||
|
#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
|
||||||
|
|
||||||
|
#define READ_BIT(REG, BIT) ((REG) & (BIT))
|
||||||
|
|
||||||
|
#define CLEAR_REG(REG) ((REG) = (0x0))
|
||||||
|
|
||||||
|
#define WRITE_REG(REG, VAL) ((REG) = (VAL))
|
||||||
|
|
||||||
|
#define READ_REG(REG) ((REG))
|
||||||
|
|
||||||
|
#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* __STM32F0xx_H */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
217
F1-nolib/inc/Fx/stm32f1.h
Normal file
217
F1-nolib/inc/Fx/stm32f1.h
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
/*
|
||||||
|
* stm32f1.h
|
||||||
|
*
|
||||||
|
* Copyright 2017 Edward V. Emelianoff <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#ifndef __STM32F1_H__
|
||||||
|
#define __STM32F1_H__
|
||||||
|
|
||||||
|
#include "vector.h"
|
||||||
|
#include "stm32f10x.h"
|
||||||
|
#include "common_macros.h"
|
||||||
|
|
||||||
|
|
||||||
|
/************************* RCC *************************/
|
||||||
|
// reset clocking registers
|
||||||
|
TRUE_INLINE void sysreset(void){
|
||||||
|
/* Reset the RCC clock configuration to the default reset state(for debug purpose) */
|
||||||
|
/* Set HSION bit */
|
||||||
|
RCC->CR |= (uint32_t)0x00000001;
|
||||||
|
/* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */
|
||||||
|
#ifndef STM32F10X_CL
|
||||||
|
RCC->CFGR &= (uint32_t)0xF8FF0000;
|
||||||
|
#else
|
||||||
|
RCC->CFGR &= (uint32_t)0xF0FF0000;
|
||||||
|
#endif /* STM32F10X_CL */
|
||||||
|
/* Reset HSEON, CSSON and PLLON bits */
|
||||||
|
RCC->CR &= (uint32_t)0xFEF6FFFF;
|
||||||
|
/* Reset HSEBYP bit */
|
||||||
|
RCC->CR &= (uint32_t)0xFFFBFFFF;
|
||||||
|
/* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */
|
||||||
|
RCC->CFGR &= (uint32_t)0xFF80FFFF;
|
||||||
|
#ifdef STM32F10X_CL
|
||||||
|
/* Reset PLL2ON and PLL3ON bits */
|
||||||
|
RCC->CR &= (uint32_t)0xEBFFFFFF;
|
||||||
|
/* Disable all interrupts and clear pending bits */
|
||||||
|
RCC->CIR = 0x00FF0000;
|
||||||
|
/* Reset CFGR2 register */
|
||||||
|
RCC->CFGR2 = 0x00000000;
|
||||||
|
#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || (defined STM32F10X_HD_VL)
|
||||||
|
/* Disable all interrupts and clear pending bits */
|
||||||
|
RCC->CIR = 0x009F0000;
|
||||||
|
/* Reset CFGR2 register */
|
||||||
|
RCC->CFGR2 = 0x00000000;
|
||||||
|
#else
|
||||||
|
/* Disable all interrupts and clear pending bits */
|
||||||
|
RCC->CIR = 0x009F0000;
|
||||||
|
#endif /* STM32F10X_CL */
|
||||||
|
|
||||||
|
#ifdef VECT_TAB_SRAM
|
||||||
|
SCB->VTOR = SRAM_BASE; /* Vector Table Relocation in Internal SRAM. */
|
||||||
|
#else
|
||||||
|
SCB->VTOR = FLASH_BASE; /* Vector Table Relocation in Internal FLASH. */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
TRUE_INLINE void StartHSE()
|
||||||
|
{
|
||||||
|
__IO uint32_t StartUpCounter = 0;
|
||||||
|
|
||||||
|
/* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/
|
||||||
|
/* Enable HSE */
|
||||||
|
RCC->CR |= ((uint32_t)RCC_CR_HSEON);
|
||||||
|
|
||||||
|
/* Wait till HSE is ready and if Time out is reached exit */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
++StartUpCounter;
|
||||||
|
} while(!(RCC->CR & RCC_CR_HSERDY) && (StartUpCounter < 10000));
|
||||||
|
|
||||||
|
|
||||||
|
if (RCC->CR & RCC_CR_HSERDY) // HSE started
|
||||||
|
{
|
||||||
|
/* Enable Prefetch Buffer */
|
||||||
|
FLASH->ACR |= FLASH_ACR_PRFTBE;
|
||||||
|
|
||||||
|
/* Flash 2 wait state */
|
||||||
|
FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY);
|
||||||
|
FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_2;
|
||||||
|
|
||||||
|
/* HCLK = SYSCLK */
|
||||||
|
RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
|
||||||
|
|
||||||
|
/* PCLK2 = HCLK */
|
||||||
|
RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;
|
||||||
|
|
||||||
|
/* PCLK1 = HCLK */
|
||||||
|
RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2;
|
||||||
|
|
||||||
|
#ifdef STM32F10X_CL
|
||||||
|
/* Configure PLLs ------------------------------------------------------*/
|
||||||
|
/* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */
|
||||||
|
/* PREDIV1 configuration: PREDIV1CLK = PLL2 / 5 = 8 MHz */
|
||||||
|
|
||||||
|
RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
|
||||||
|
RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC);
|
||||||
|
RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV5 | RCC_CFGR2_PLL2MUL8 |
|
||||||
|
RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV5);
|
||||||
|
|
||||||
|
/* Enable PLL2 */
|
||||||
|
RCC->CR |= RCC_CR_PLL2ON;
|
||||||
|
/* Wait till PLL2 is ready */
|
||||||
|
while((RCC->CR & RCC_CR_PLL2RDY) == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* PLL configuration: PLLCLK = PREDIV1 * 9 = 72 MHz */
|
||||||
|
RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL);
|
||||||
|
RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 |
|
||||||
|
RCC_CFGR_PLLMULL9);
|
||||||
|
#else
|
||||||
|
/* PLL configuration: PLLCLK = HSE * 9 = 72 MHz */
|
||||||
|
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE |
|
||||||
|
RCC_CFGR_PLLMULL));
|
||||||
|
RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL9);
|
||||||
|
#endif /* STM32F10X_CL */
|
||||||
|
|
||||||
|
/* Enable PLL */
|
||||||
|
RCC->CR |= RCC_CR_PLLON;
|
||||||
|
|
||||||
|
/* Wait till PLL is ready */
|
||||||
|
while((RCC->CR & RCC_CR_PLLRDY) == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Select PLL as system clock source */
|
||||||
|
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
|
||||||
|
RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
|
||||||
|
|
||||||
|
/* Wait till PLL is used as system clock source */
|
||||||
|
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // HSE fails to start-up
|
||||||
|
{
|
||||||
|
; // add some code here (use HSI)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/************************* GPIO *************************/
|
||||||
|
/**
|
||||||
|
CNF1: 0 - general output or input; 1 - alternate output or pullup/down input
|
||||||
|
CNF0: 0 - push/pull, analog or pullup/down input
|
||||||
|
MODE: 00 - input, 01 - 10MHz, 10 - 2MHz, 11 - 50MHz
|
||||||
|
Pullup/down: ODR = 0 - pulldown, 1 - pullup
|
||||||
|
GPIO_BSRR and BRR also works
|
||||||
|
IDR - input, ODR - output (or pullups management),
|
||||||
|
*/
|
||||||
|
// MODE:
|
||||||
|
#define MODE_INPUT 0
|
||||||
|
#define MODE_NORMAL 1 // 10MHz
|
||||||
|
#define MODE_SLOW 2 // 2MHz
|
||||||
|
#define MODE_FAST 3 // 50MHz
|
||||||
|
// CNF:
|
||||||
|
#define CNF_ANALOG (0 << 2)
|
||||||
|
#define CNF_PPOUTPUT (0 << 2)
|
||||||
|
#define CNF_FLINPUT (1 << 2)
|
||||||
|
#define CNF_ODOUTPUT (1 << 2)
|
||||||
|
#define CNF_PUDINPUT (2 << 2)
|
||||||
|
#define CNF_AFPP (2 << 2)
|
||||||
|
#define CNF_AFOD (3 << 2)
|
||||||
|
|
||||||
|
#define CRL(pin, cnfmode) ((cnfmode) << (pin*4))
|
||||||
|
#define CRH(pin, cnfmode) ((cnfmode) << ((pin-8)*4))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/************************* ADC *************************/
|
||||||
|
/* inner termometer calibration values
|
||||||
|
* Temp = (V30 - Vsense)/Avg_Slope + 30
|
||||||
|
* Avg_Slope = (V30 - V110) / (110 - 30)
|
||||||
|
*/
|
||||||
|
#define TEMP110_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7C2))
|
||||||
|
#define TEMP30_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7B8))
|
||||||
|
// VDDA_Actual = 3.3V * VREFINT_CAL / average vref value
|
||||||
|
#define VREFINT_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7BA))
|
||||||
|
#define VDD_CALIB ((uint16_t) (330))
|
||||||
|
#define VDD_APPLI ((uint16_t) (300))
|
||||||
|
|
||||||
|
/************************* USART *************************/
|
||||||
|
|
||||||
|
#define USART_CR2_ADD_SHIFT 24
|
||||||
|
// set address/character match value
|
||||||
|
#define USART_CR2_ADD_VAL(x) ((x) << USART_CR2_ADD_SHIFT)
|
||||||
|
|
||||||
|
/************************* IWDG *************************/
|
||||||
|
#define IWDG_REFRESH (uint32_t)(0x0000AAAA)
|
||||||
|
#define IWDG_WRITE_ACCESS (uint32_t)(0x00005555)
|
||||||
|
#define IWDG_START (uint32_t)(0x0000CCCC)
|
||||||
|
|
||||||
|
|
||||||
|
//#define do{}while(0)
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __STM32F1_H__
|
||||||
8353
F1-nolib/inc/Fx/stm32f10x.h
Normal file
8353
F1-nolib/inc/Fx/stm32f10x.h
Normal file
File diff suppressed because it is too large
Load Diff
418
F1-nolib/inc/Fx/vector.h
Normal file
418
F1-nolib/inc/Fx/vector.h
Normal file
@ -0,0 +1,418 @@
|
|||||||
|
/*
|
||||||
|
* vector.h
|
||||||
|
*
|
||||||
|
* Copyright 2017 Edward V. Emelianoff <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#ifndef VECTOR_H
|
||||||
|
#define VECTOR_H
|
||||||
|
|
||||||
|
typedef void (*vector_table_entry_t)(void);
|
||||||
|
typedef void (*funcp_t) (void);
|
||||||
|
/* Symbols exported by the linker script(s): */
|
||||||
|
extern unsigned _data_loadaddr, _data, _edata, _ebss, _stack;
|
||||||
|
extern funcp_t __preinit_array_start, __preinit_array_end;
|
||||||
|
extern funcp_t __init_array_start, __init_array_end;
|
||||||
|
extern funcp_t __fini_array_start, __fini_array_end;
|
||||||
|
|
||||||
|
#ifndef WEAK
|
||||||
|
#define WEAK __attribute__((weak))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void WEAK reset_handler(void);
|
||||||
|
void WEAK nmi_handler(void);
|
||||||
|
void WEAK hard_fault_handler(void);
|
||||||
|
void WEAK sv_call_handler(void);
|
||||||
|
void WEAK pend_sv_handler(void);
|
||||||
|
void WEAK sys_tick_handler(void);
|
||||||
|
|
||||||
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
||||||
|
void WEAK mem_manage_handler(void);
|
||||||
|
void WEAK bus_fault_handler(void);
|
||||||
|
void WEAK usage_fault_handler(void);
|
||||||
|
void WEAK debug_monitor_handler(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined STM32F0
|
||||||
|
void WEAK wwdg_isr(void);
|
||||||
|
void WEAK pvd_isr(void);
|
||||||
|
void WEAK rtc_isr(void);
|
||||||
|
void WEAK flash_isr(void);
|
||||||
|
void WEAK rcc_isr(void);
|
||||||
|
void WEAK exti0_1_isr(void);
|
||||||
|
void WEAK exti2_3_isr(void);
|
||||||
|
void WEAK exti4_15_isr(void);
|
||||||
|
void WEAK tsc_isr(void);
|
||||||
|
void WEAK dma1_channel1_isr(void);
|
||||||
|
void WEAK dma1_channel2_3_isr(void);
|
||||||
|
void WEAK dma1_channel4_5_isr(void);
|
||||||
|
void WEAK adc_comp_isr(void);
|
||||||
|
void WEAK tim1_brk_up_trg_com_isr(void);
|
||||||
|
void WEAK tim1_cc_isr(void);
|
||||||
|
void WEAK tim2_isr(void);
|
||||||
|
void WEAK tim3_isr(void);
|
||||||
|
void WEAK tim6_dac_isr(void);
|
||||||
|
void WEAK tim7_isr(void);
|
||||||
|
void WEAK tim14_isr(void);
|
||||||
|
void WEAK tim15_isr(void);
|
||||||
|
void WEAK tim16_isr(void);
|
||||||
|
void WEAK tim17_isr(void);
|
||||||
|
void WEAK i2c1_isr(void);
|
||||||
|
void WEAK i2c2_isr(void);
|
||||||
|
void WEAK spi1_isr(void);
|
||||||
|
void WEAK spi2_isr(void);
|
||||||
|
void WEAK usart1_isr(void);
|
||||||
|
void WEAK usart2_isr(void);
|
||||||
|
void WEAK usart3_4_isr(void);
|
||||||
|
void WEAK cec_can_isr(void);
|
||||||
|
void WEAK usb_isr(void);
|
||||||
|
|
||||||
|
#elif defined STM32F1
|
||||||
|
void WEAK wwdg_isr(void);
|
||||||
|
void WEAK pvd_isr(void);
|
||||||
|
void WEAK tamper_isr(void);
|
||||||
|
void WEAK rtc_isr(void);
|
||||||
|
void WEAK flash_isr(void);
|
||||||
|
void WEAK rcc_isr(void);
|
||||||
|
void WEAK exti0_isr(void);
|
||||||
|
void WEAK exti1_isr(void);
|
||||||
|
void WEAK exti2_isr(void);
|
||||||
|
void WEAK exti3_isr(void);
|
||||||
|
void WEAK exti4_isr(void);
|
||||||
|
void WEAK dma1_channel1_isr(void);
|
||||||
|
void WEAK dma1_channel2_isr(void);
|
||||||
|
void WEAK dma1_channel3_isr(void);
|
||||||
|
void WEAK dma1_channel4_isr(void);
|
||||||
|
void WEAK dma1_channel5_isr(void);
|
||||||
|
void WEAK dma1_channel6_isr(void);
|
||||||
|
void WEAK dma1_channel7_isr(void);
|
||||||
|
void WEAK adc1_2_isr(void);
|
||||||
|
void WEAK usb_hp_can_tx_isr(void);
|
||||||
|
void WEAK usb_lp_can_rx0_isr(void);
|
||||||
|
void WEAK can_rx1_isr(void);
|
||||||
|
void WEAK can_sce_isr(void);
|
||||||
|
void WEAK exti9_5_isr(void);
|
||||||
|
void WEAK tim1_brk_isr(void);
|
||||||
|
void WEAK tim1_up_isr(void);
|
||||||
|
void WEAK tim1_trg_com_isr(void);
|
||||||
|
void WEAK tim1_cc_isr(void);
|
||||||
|
void WEAK tim2_isr(void);
|
||||||
|
void WEAK tim3_isr(void);
|
||||||
|
void WEAK tim4_isr(void);
|
||||||
|
void WEAK i2c1_ev_isr(void);
|
||||||
|
void WEAK i2c1_er_isr(void);
|
||||||
|
void WEAK i2c2_ev_isr(void);
|
||||||
|
void WEAK i2c2_er_isr(void);
|
||||||
|
void WEAK spi1_isr(void);
|
||||||
|
void WEAK spi2_isr(void);
|
||||||
|
void WEAK usart1_isr(void);
|
||||||
|
void WEAK usart2_isr(void);
|
||||||
|
void WEAK usart3_isr(void);
|
||||||
|
void WEAK exti15_10_isr(void);
|
||||||
|
void WEAK rtc_alarm_isr(void);
|
||||||
|
void WEAK usb_wakeup_isr(void);
|
||||||
|
void WEAK tim8_brk_isr(void);
|
||||||
|
void WEAK tim8_up_isr(void);
|
||||||
|
void WEAK tim8_trg_com_isr(void);
|
||||||
|
void WEAK tim8_cc_isr(void);
|
||||||
|
void WEAK adc3_isr(void);
|
||||||
|
void WEAK fsmc_isr(void);
|
||||||
|
void WEAK sdio_isr(void);
|
||||||
|
void WEAK tim5_isr(void);
|
||||||
|
void WEAK spi3_isr(void);
|
||||||
|
void WEAK uart4_isr(void);
|
||||||
|
void WEAK uart5_isr(void);
|
||||||
|
void WEAK tim6_isr(void);
|
||||||
|
void WEAK tim7_isr(void);
|
||||||
|
void WEAK dma2_channel1_isr(void);
|
||||||
|
void WEAK dma2_channel2_isr(void);
|
||||||
|
void WEAK dma2_channel3_isr(void);
|
||||||
|
void WEAK dma2_channel4_5_isr(void);
|
||||||
|
void WEAK dma2_channel5_isr(void);
|
||||||
|
void WEAK eth_isr(void);
|
||||||
|
void WEAK eth_wkup_isr(void);
|
||||||
|
void WEAK can2_tx_isr(void);
|
||||||
|
void WEAK can2_rx0_isr(void);
|
||||||
|
void WEAK can2_rx1_isr(void);
|
||||||
|
void WEAK can2_sce_isr(void);
|
||||||
|
void WEAK otg_fs_isr(void);
|
||||||
|
|
||||||
|
#elif defined STM32F2
|
||||||
|
void WEAK nvic_wwdg_isr(void);
|
||||||
|
void WEAK pvd_isr(void);
|
||||||
|
void WEAK tamp_stamp_isr(void);
|
||||||
|
void WEAK rtc_wkup_isr(void);
|
||||||
|
void WEAK flash_isr(void);
|
||||||
|
void WEAK rcc_isr(void);
|
||||||
|
void WEAK exti0_isr(void);
|
||||||
|
void WEAK exti1_isr(void);
|
||||||
|
void WEAK exti2_isr(void);
|
||||||
|
void WEAK exti3_isr(void);
|
||||||
|
void WEAK exti4_isr(void);
|
||||||
|
void WEAK dma1_stream0_isr(void);
|
||||||
|
void WEAK dma1_stream1_isr(void);
|
||||||
|
void WEAK dma1_stream2_isr(void);
|
||||||
|
void WEAK dma1_stream3_isr(void);
|
||||||
|
void WEAK dma1_stream4_isr(void);
|
||||||
|
void WEAK dma1_stream5_isr(void);
|
||||||
|
void WEAK dma1_stream6_isr(void);
|
||||||
|
void WEAK adc_isr(void);
|
||||||
|
void WEAK can1_tx_isr(void);
|
||||||
|
void WEAK can1_rx0_isr(void);
|
||||||
|
void WEAK can1_rx1_isr(void);
|
||||||
|
void WEAK can1_sce_isr(void);
|
||||||
|
void WEAK exti9_5_isr(void);
|
||||||
|
void WEAK tim1_brk_tim9_isr(void);
|
||||||
|
void WEAK tim1_up_tim10_isr(void);
|
||||||
|
void WEAK tim1_trg_com_tim11_isr(void);
|
||||||
|
void WEAK tim1_cc_isr(void);
|
||||||
|
void WEAK tim2_isr(void);
|
||||||
|
void WEAK tim3_isr(void);
|
||||||
|
void WEAK tim4_isr(void);
|
||||||
|
void WEAK i2c1_ev_isr(void);
|
||||||
|
void WEAK i2c1_er_isr(void);
|
||||||
|
void WEAK i2c2_ev_isr(void);
|
||||||
|
void WEAK i2c2_er_isr(void);
|
||||||
|
void WEAK spi1_isr(void);
|
||||||
|
void WEAK spi2_isr(void);
|
||||||
|
void WEAK usart1_isr(void);
|
||||||
|
void WEAK usart2_isr(void);
|
||||||
|
void WEAK usart3_isr(void);
|
||||||
|
void WEAK exti15_10_isr(void);
|
||||||
|
void WEAK rtc_alarm_isr(void);
|
||||||
|
void WEAK usb_fs_wkup_isr(void);
|
||||||
|
void WEAK tim8_brk_tim12_isr(void);
|
||||||
|
void WEAK tim8_up_tim13_isr(void);
|
||||||
|
void WEAK tim8_trg_com_tim14_isr(void);
|
||||||
|
void WEAK tim8_cc_isr(void);
|
||||||
|
void WEAK dma1_stream7_isr(void);
|
||||||
|
void WEAK fsmc_isr(void);
|
||||||
|
void WEAK sdio_isr(void);
|
||||||
|
void WEAK tim5_isr(void);
|
||||||
|
void WEAK spi3_isr(void);
|
||||||
|
void WEAK uart4_isr(void);
|
||||||
|
void WEAK uart5_isr(void);
|
||||||
|
void WEAK tim6_dac_isr(void);
|
||||||
|
void WEAK tim7_isr(void);
|
||||||
|
void WEAK dma2_stream0_isr(void);
|
||||||
|
void WEAK dma2_stream1_isr(void);
|
||||||
|
void WEAK dma2_stream2_isr(void);
|
||||||
|
void WEAK dma2_stream3_isr(void);
|
||||||
|
void WEAK dma2_stream4_isr(void);
|
||||||
|
void WEAK eth_isr(void);
|
||||||
|
void WEAK eth_wkup_isr(void);
|
||||||
|
void WEAK can2_tx_isr(void);
|
||||||
|
void WEAK can2_rx0_isr(void);
|
||||||
|
void WEAK can2_rx1_isr(void);
|
||||||
|
void WEAK can2_sce_isr(void);
|
||||||
|
void WEAK otg_fs_isr(void);
|
||||||
|
void WEAK dma2_stream5_isr(void);
|
||||||
|
void WEAK dma2_stream6_isr(void);
|
||||||
|
void WEAK dma2_stream7_isr(void);
|
||||||
|
void WEAK usart6_isr(void);
|
||||||
|
void WEAK i2c3_ev_isr(void);
|
||||||
|
void WEAK i2c3_er_isr(void);
|
||||||
|
void WEAK otg_hs_ep1_out_isr(void);
|
||||||
|
void WEAK otg_hs_ep1_in_isr(void);
|
||||||
|
void WEAK otg_hs_wkup_isr(void);
|
||||||
|
void WEAK otg_hs_isr(void);
|
||||||
|
void WEAK dcmi_isr(void);
|
||||||
|
void WEAK cryp_isr(void);
|
||||||
|
void WEAK hash_rng_isr(void);
|
||||||
|
|
||||||
|
#elif defined STM32F3
|
||||||
|
void WEAK nvic_wwdg_isr(void);
|
||||||
|
void WEAK pvd_isr(void);
|
||||||
|
void WEAK tamp_stamp_isr(void);
|
||||||
|
void WEAK rtc_wkup_isr(void);
|
||||||
|
void WEAK flash_isr(void);
|
||||||
|
void WEAK rcc_isr(void);
|
||||||
|
void WEAK exti0_isr(void);
|
||||||
|
void WEAK exti1_isr(void);
|
||||||
|
void WEAK exti2_tsc_isr(void);
|
||||||
|
void WEAK exti3_isr(void);
|
||||||
|
void WEAK exti4_isr(void);
|
||||||
|
void WEAK dma1_channel1_isr(void);
|
||||||
|
void WEAK dma1_channel2_isr(void);
|
||||||
|
void WEAK dma1_channel3_isr(void);
|
||||||
|
void WEAK dma1_channel4_isr(void);
|
||||||
|
void WEAK dma1_channel5_isr(void);
|
||||||
|
void WEAK dma1_channel6_isr(void);
|
||||||
|
void WEAK dma1_channel7_isr(void);
|
||||||
|
void WEAK adc1_2_isr(void);
|
||||||
|
void WEAK usb_hp_can1_tx_isr(void);
|
||||||
|
void WEAK usb_lp_can1_rx0_isr(void);
|
||||||
|
void WEAK can1_rx1_isr(void);
|
||||||
|
void WEAK can1_sce_isr(void);
|
||||||
|
void WEAK exti9_5_isr(void);
|
||||||
|
void WEAK tim1_brk_tim15_isr(void);
|
||||||
|
void WEAK tim1_up_tim16_isr(void);
|
||||||
|
void WEAK tim1_trg_com_tim17_isr(void);
|
||||||
|
void WEAK tim1_cc_isr(void);
|
||||||
|
void WEAK tim2_isr(void);
|
||||||
|
void WEAK tim3_isr(void);
|
||||||
|
void WEAK tim4_isr(void);
|
||||||
|
void WEAK i2c1_ev_exti23_isr(void);
|
||||||
|
void WEAK i2c1_er_isr(void);
|
||||||
|
void WEAK i2c2_ev_exti24_isr(void);
|
||||||
|
void WEAK i2c2_er_isr(void);
|
||||||
|
void WEAK spi1_isr(void);
|
||||||
|
void WEAK spi2_isr(void);
|
||||||
|
void WEAK usart1_exti25_isr(void);
|
||||||
|
void WEAK usart2_exti26_isr(void);
|
||||||
|
void WEAK usart3_exti28_isr(void);
|
||||||
|
void WEAK exti15_10_isr(void);
|
||||||
|
void WEAK rtc_alarm_isr(void);
|
||||||
|
void WEAK usb_wkup_a_isr(void);
|
||||||
|
void WEAK tim8_brk_isr(void);
|
||||||
|
void WEAK tim8_up_isr(void);
|
||||||
|
void WEAK tim8_trg_com_isr(void);
|
||||||
|
void WEAK tim8_cc_isr(void);
|
||||||
|
void WEAK adc3_isr(void);
|
||||||
|
void WEAK reserved_1_isr(void);
|
||||||
|
void WEAK reserved_2_isr(void);
|
||||||
|
void WEAK reserved_3_isr(void);
|
||||||
|
void WEAK spi3_isr(void);
|
||||||
|
void WEAK uart4_exti34_isr(void);
|
||||||
|
void WEAK uart5_exti35_isr(void);
|
||||||
|
void WEAK tim6_dac_isr(void);
|
||||||
|
void WEAK tim7_isr(void);
|
||||||
|
void WEAK dma2_channel1_isr(void);
|
||||||
|
void WEAK dma2_channel2_isr(void);
|
||||||
|
void WEAK dma2_channel3_isr(void);
|
||||||
|
void WEAK dma2_channel4_isr(void);
|
||||||
|
void WEAK dma2_channel5_isr(void);
|
||||||
|
void WEAK eth_isr(void);
|
||||||
|
void WEAK reserved_4_isr(void);
|
||||||
|
void WEAK reserved_5_isr(void);
|
||||||
|
void WEAK comp123_isr(void);
|
||||||
|
void WEAK comp456_isr(void);
|
||||||
|
void WEAK comp7_isr(void);
|
||||||
|
void WEAK reserved_6_isr(void);
|
||||||
|
void WEAK reserved_7_isr(void);
|
||||||
|
void WEAK reserved_8_isr(void);
|
||||||
|
void WEAK reserved_9_isr(void);
|
||||||
|
void WEAK reserved_10_isr(void);
|
||||||
|
void WEAK reserved_11_isr(void);
|
||||||
|
void WEAK reserved_12_isr(void);
|
||||||
|
void WEAK usb_hp_isr(void);
|
||||||
|
void WEAK usb_lp_isr(void);
|
||||||
|
void WEAK usb_wkup_isr(void);
|
||||||
|
void WEAK reserved_13_isr(void);
|
||||||
|
void WEAK reserved_14_isr(void);
|
||||||
|
void WEAK reserved_15_isr(void);
|
||||||
|
void WEAK reserved_16_isr(void);
|
||||||
|
|
||||||
|
#elif defined STM32F4
|
||||||
|
void WEAK nvic_wwdg_isr(void);
|
||||||
|
void WEAK pvd_isr(void);
|
||||||
|
void WEAK tamp_stamp_isr(void);
|
||||||
|
void WEAK rtc_wkup_isr(void);
|
||||||
|
void WEAK flash_isr(void);
|
||||||
|
void WEAK rcc_isr(void);
|
||||||
|
void WEAK exti0_isr(void);
|
||||||
|
void WEAK exti1_isr(void);
|
||||||
|
void WEAK exti2_isr(void);
|
||||||
|
void WEAK exti3_isr(void);
|
||||||
|
void WEAK exti4_isr(void);
|
||||||
|
void WEAK dma1_stream0_isr(void);
|
||||||
|
void WEAK dma1_stream1_isr(void);
|
||||||
|
void WEAK dma1_stream2_isr(void);
|
||||||
|
void WEAK dma1_stream3_isr(void);
|
||||||
|
void WEAK dma1_stream4_isr(void);
|
||||||
|
void WEAK dma1_stream5_isr(void);
|
||||||
|
void WEAK dma1_stream6_isr(void);
|
||||||
|
void WEAK adc_isr(void);
|
||||||
|
void WEAK can1_tx_isr(void);
|
||||||
|
void WEAK can1_rx0_isr(void);
|
||||||
|
void WEAK can1_rx1_isr(void);
|
||||||
|
void WEAK can1_sce_isr(void);
|
||||||
|
void WEAK exti9_5_isr(void);
|
||||||
|
void WEAK tim1_brk_tim9_isr(void);
|
||||||
|
void WEAK tim1_up_tim10_isr(void);
|
||||||
|
void WEAK tim1_trg_com_tim11_isr(void);
|
||||||
|
void WEAK tim1_cc_isr(void);
|
||||||
|
void WEAK tim2_isr(void);
|
||||||
|
void WEAK tim3_isr(void);
|
||||||
|
void WEAK tim4_isr(void);
|
||||||
|
void WEAK i2c1_ev_isr(void);
|
||||||
|
void WEAK i2c1_er_isr(void);
|
||||||
|
void WEAK i2c2_ev_isr(void);
|
||||||
|
void WEAK i2c2_er_isr(void);
|
||||||
|
void WEAK spi1_isr(void);
|
||||||
|
void WEAK spi2_isr(void);
|
||||||
|
void WEAK usart1_isr(void);
|
||||||
|
void WEAK usart2_isr(void);
|
||||||
|
void WEAK usart3_isr(void);
|
||||||
|
void WEAK exti15_10_isr(void);
|
||||||
|
void WEAK rtc_alarm_isr(void);
|
||||||
|
void WEAK usb_fs_wkup_isr(void);
|
||||||
|
void WEAK tim8_brk_tim12_isr(void);
|
||||||
|
void WEAK tim8_up_tim13_isr(void);
|
||||||
|
void WEAK tim8_trg_com_tim14_isr(void);
|
||||||
|
void WEAK tim8_cc_isr(void);
|
||||||
|
void WEAK dma1_stream7_isr(void);
|
||||||
|
void WEAK fsmc_isr(void);
|
||||||
|
void WEAK sdio_isr(void);
|
||||||
|
void WEAK tim5_isr(void);
|
||||||
|
void WEAK spi3_isr(void);
|
||||||
|
void WEAK uart4_isr(void);
|
||||||
|
void WEAK uart5_isr(void);
|
||||||
|
void WEAK tim6_dac_isr(void);
|
||||||
|
void WEAK tim7_isr(void);
|
||||||
|
void WEAK dma2_stream0_isr(void);
|
||||||
|
void WEAK dma2_stream1_isr(void);
|
||||||
|
void WEAK dma2_stream2_isr(void);
|
||||||
|
void WEAK dma2_stream3_isr(void);
|
||||||
|
void WEAK dma2_stream4_isr(void);
|
||||||
|
void WEAK eth_isr(void);
|
||||||
|
void WEAK eth_wkup_isr(void);
|
||||||
|
void WEAK can2_tx_isr(void);
|
||||||
|
void WEAK can2_rx0_isr(void);
|
||||||
|
void WEAK can2_rx1_isr(void);
|
||||||
|
void WEAK can2_sce_isr(void);
|
||||||
|
void WEAK otg_fs_isr(void);
|
||||||
|
void WEAK dma2_stream5_isr(void);
|
||||||
|
void WEAK dma2_stream6_isr(void);
|
||||||
|
void WEAK dma2_stream7_isr(void);
|
||||||
|
void WEAK usart6_isr(void);
|
||||||
|
void WEAK i2c3_ev_isr(void);
|
||||||
|
void WEAK i2c3_er_isr(void);
|
||||||
|
void WEAK otg_hs_ep1_out_isr(void);
|
||||||
|
void WEAK otg_hs_ep1_in_isr(void);
|
||||||
|
void WEAK otg_hs_wkup_isr(void);
|
||||||
|
void WEAK otg_hs_isr(void);
|
||||||
|
void WEAK dcmi_isr(void);
|
||||||
|
void WEAK cryp_isr(void);
|
||||||
|
void WEAK hash_rng_isr(void);
|
||||||
|
void WEAK fpu_isr(void);
|
||||||
|
void WEAK uart7_isr(void);
|
||||||
|
void WEAK uart8_isr(void);
|
||||||
|
void WEAK spi4_isr(void);
|
||||||
|
void WEAK spi5_isr(void);
|
||||||
|
void WEAK spi6_isr(void);
|
||||||
|
void WEAK sai1_isr(void);
|
||||||
|
void WEAK lcd_tft_isr(void);
|
||||||
|
void WEAK lcd_tft_err_isr(void);
|
||||||
|
void WEAK dma2d_isr(void);
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Not supported platform"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // VECTOR_H
|
||||||
1
F1-nolib/inc/README
Normal file
1
F1-nolib/inc/README
Normal file
@ -0,0 +1 @@
|
|||||||
|
including files
|
||||||
713
F1-nolib/inc/cm/core_cm0.h
Normal file
713
F1-nolib/inc/cm/core_cm0.h
Normal file
@ -0,0 +1,713 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_cm0.h
|
||||||
|
* @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File
|
||||||
|
* @version V4.00
|
||||||
|
* @date 22. August 2014
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2014 ARM LIMITED
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
- Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CORE_CM0_H_GENERIC
|
||||||
|
#define __CORE_CM0_H_GENERIC
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
|
||||||
|
CMSIS violates the following MISRA-C:2004 rules:
|
||||||
|
|
||||||
|
\li Required Rule 8.5, object/function definition in header file.<br>
|
||||||
|
Function definitions in header files are used to allow 'inlining'.
|
||||||
|
|
||||||
|
\li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
|
||||||
|
Unions are used for effective representation of core registers.
|
||||||
|
|
||||||
|
\li Advisory Rule 19.7, Function-like macro defined.<br>
|
||||||
|
Function-like macros are used to allow more efficient code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* CMSIS definitions
|
||||||
|
******************************************************************************/
|
||||||
|
/** \ingroup Cortex_M0
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* CMSIS CM0 definitions */
|
||||||
|
#define __CM0_CMSIS_VERSION_MAIN (0x04) /*!< [31:16] CMSIS HAL main version */
|
||||||
|
#define __CM0_CMSIS_VERSION_SUB (0x00) /*!< [15:0] CMSIS HAL sub version */
|
||||||
|
#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16) | \
|
||||||
|
__CM0_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
|
||||||
|
|
||||||
|
#define __CORTEX_M (0x00) /*!< Cortex-M Core */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#define __ASM __asm /*!< asm keyword for ARM Compiler */
|
||||||
|
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
|
||||||
|
#define __STATIC_INLINE static __inline
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for GNU Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for GNU Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for IAR Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TI CCS Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for TASKING Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#define __packed
|
||||||
|
#define __ASM _asm /*!< asm keyword for COSMIC Compiler */
|
||||||
|
#define __INLINE inline /*use -pc99 on compile line !< inline keyword for COSMIC Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** __FPU_USED indicates whether an FPU is used or not.
|
||||||
|
This core does not support an FPU at all
|
||||||
|
*/
|
||||||
|
#define __FPU_USED 0
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#if defined __TARGET_FPU_VFP
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#if defined __ARMVFP__
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#if defined __TI__VFP_SUPPORT____
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#if defined __FPU_VFP__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ ) /* Cosmic */
|
||||||
|
#if ( __CSMC__ & 0x400) // FPU present for parser
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h> /* standard types definitions */
|
||||||
|
#include <core_cmInstr.h> /* Core Instruction Access */
|
||||||
|
#include <core_cmFunc.h> /* Core Function Access */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_CM0_H_GENERIC */
|
||||||
|
|
||||||
|
#ifndef __CMSIS_GENERIC
|
||||||
|
|
||||||
|
#ifndef __CORE_CM0_H_DEPENDANT
|
||||||
|
#define __CORE_CM0_H_DEPENDANT
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* check device defines and use defaults */
|
||||||
|
#if defined __CHECK_DEVICE_DEFINES
|
||||||
|
#ifndef __CM0_REV
|
||||||
|
#define __CM0_REV 0x0000
|
||||||
|
#warning "__CM0_REV not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __NVIC_PRIO_BITS
|
||||||
|
#define __NVIC_PRIO_BITS 2
|
||||||
|
#warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __Vendor_SysTickConfig
|
||||||
|
#define __Vendor_SysTickConfig 0
|
||||||
|
#warning "__Vendor_SysTickConfig not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* IO definitions (access restrictions to peripheral registers) */
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_glob_defs CMSIS Global Defines
|
||||||
|
|
||||||
|
<strong>IO Type Qualifiers</strong> are used
|
||||||
|
\li to specify the access to peripheral variables.
|
||||||
|
\li for automatic generation of peripheral register debug information.
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define __I volatile /*!< Defines 'read only' permissions */
|
||||||
|
#else
|
||||||
|
#define __I volatile const /*!< Defines 'read only' permissions */
|
||||||
|
#endif
|
||||||
|
#define __O volatile /*!< Defines 'write only' permissions */
|
||||||
|
#define __IO volatile /*!< Defines 'read / write' permissions */
|
||||||
|
|
||||||
|
/*@} end of group Cortex_M0 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Register Abstraction
|
||||||
|
Core Register contain:
|
||||||
|
- Core Register
|
||||||
|
- Core NVIC Register
|
||||||
|
- Core SCB Register
|
||||||
|
- Core SysTick Register
|
||||||
|
******************************************************************************/
|
||||||
|
/** \defgroup CMSIS_core_register Defines and Type Definitions
|
||||||
|
\brief Type definitions and defines for Cortex-M processor based devices.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CORE Status and Control Registers
|
||||||
|
\brief Core Register type definitions.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Union type to access the Application Program Status Register (APSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
#if (__CORTEX_M != 0x04)
|
||||||
|
uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */
|
||||||
|
#else
|
||||||
|
uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */
|
||||||
|
uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
|
||||||
|
uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */
|
||||||
|
#endif
|
||||||
|
uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} APSR_Type;
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Union type to access the Interrupt Program Status Register (IPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} IPSR_Type;
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Union type to access the Special-Purpose Program Status Registers (xPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
#if (__CORTEX_M != 0x04)
|
||||||
|
uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
|
||||||
|
#else
|
||||||
|
uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */
|
||||||
|
uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
|
||||||
|
uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */
|
||||||
|
#endif
|
||||||
|
uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
|
||||||
|
uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */
|
||||||
|
uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} xPSR_Type;
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Union type to access the Control Registers (CONTROL).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */
|
||||||
|
uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
|
||||||
|
uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */
|
||||||
|
uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} CONTROL_Type;
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_CORE */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
|
||||||
|
\brief Type definitions for the NVIC Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IO uint32_t ISER[1]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
|
||||||
|
uint32_t RESERVED0[31];
|
||||||
|
__IO uint32_t ICER[1]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
|
||||||
|
uint32_t RSERVED1[31];
|
||||||
|
__IO uint32_t ISPR[1]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
|
||||||
|
uint32_t RESERVED2[31];
|
||||||
|
__IO uint32_t ICPR[1]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
|
||||||
|
uint32_t RESERVED3[31];
|
||||||
|
uint32_t RESERVED4[64];
|
||||||
|
__IO uint32_t IP[8]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
|
||||||
|
} NVIC_Type;
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_NVIC */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SCB System Control Block (SCB)
|
||||||
|
\brief Type definitions for the System Control Block Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the System Control Block (SCB).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__I uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
|
||||||
|
__IO uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
|
||||||
|
uint32_t RESERVED0;
|
||||||
|
__IO uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
|
||||||
|
__IO uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
|
||||||
|
__IO uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
|
||||||
|
uint32_t RESERVED1;
|
||||||
|
__IO uint32_t SHP[2]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
|
||||||
|
__IO uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
|
||||||
|
} SCB_Type;
|
||||||
|
|
||||||
|
/* SCB CPUID Register Definitions */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Pos 24 /*!< SCB CPUID: IMPLEMENTER Position */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_VARIANT_Pos 20 /*!< SCB CPUID: VARIANT Position */
|
||||||
|
#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Pos 16 /*!< SCB CPUID: ARCHITECTURE Position */
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_PARTNO_Pos 4 /*!< SCB CPUID: PARTNO Position */
|
||||||
|
#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_REVISION_Pos 0 /*!< SCB CPUID: REVISION Position */
|
||||||
|
#define SCB_CPUID_REVISION_Msk (0xFUL << SCB_CPUID_REVISION_Pos) /*!< SCB CPUID: REVISION Mask */
|
||||||
|
|
||||||
|
/* SCB Interrupt Control State Register Definitions */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Pos 31 /*!< SCB ICSR: NMIPENDSET Position */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVSET_Pos 28 /*!< SCB ICSR: PENDSVSET Position */
|
||||||
|
#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Pos 27 /*!< SCB ICSR: PENDSVCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTSET_Pos 26 /*!< SCB ICSR: PENDSTSET Position */
|
||||||
|
#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Pos 25 /*!< SCB ICSR: PENDSTCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Pos 23 /*!< SCB ICSR: ISRPREEMPT Position */
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPENDING_Pos 22 /*!< SCB ICSR: ISRPENDING Position */
|
||||||
|
#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTPENDING_Pos 12 /*!< SCB ICSR: VECTPENDING Position */
|
||||||
|
#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Pos 0 /*!< SCB ICSR: VECTACTIVE Position */
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos) /*!< SCB ICSR: VECTACTIVE Mask */
|
||||||
|
|
||||||
|
/* SCB Application Interrupt and Reset Control Register Definitions */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Pos 16 /*!< SCB AIRCR: VECTKEY Position */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Pos 16 /*!< SCB AIRCR: VECTKEYSTAT Position */
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Pos 15 /*!< SCB AIRCR: ENDIANESS Position */
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Pos 2 /*!< SCB AIRCR: SYSRESETREQ Position */
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Pos 1 /*!< SCB AIRCR: VECTCLRACTIVE Position */
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
|
||||||
|
|
||||||
|
/* SCB System Control Register Definitions */
|
||||||
|
#define SCB_SCR_SEVONPEND_Pos 4 /*!< SCB SCR: SEVONPEND Position */
|
||||||
|
#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Pos 2 /*!< SCB SCR: SLEEPDEEP Position */
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Pos 1 /*!< SCB SCR: SLEEPONEXIT Position */
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
|
||||||
|
|
||||||
|
/* SCB Configuration Control Register Definitions */
|
||||||
|
#define SCB_CCR_STKALIGN_Pos 9 /*!< SCB CCR: STKALIGN Position */
|
||||||
|
#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
|
||||||
|
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Pos 3 /*!< SCB CCR: UNALIGN_TRP Position */
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
|
||||||
|
|
||||||
|
/* SCB System Handler Control and State Register Definitions */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Pos 15 /*!< SCB SHCSR: SVCALLPENDED Position */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SCB */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SysTick System Tick Timer (SysTick)
|
||||||
|
\brief Type definitions for the System Timer Registers.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the System Timer (SysTick).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IO uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
|
||||||
|
__IO uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
|
||||||
|
__IO uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
|
||||||
|
__I uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
|
||||||
|
} SysTick_Type;
|
||||||
|
|
||||||
|
/* SysTick Control / Status Register Definitions */
|
||||||
|
// == 0 if counted to 0 since last reading
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Pos 16 /*!< SysTick CTRL: COUNTFLAG Position */
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
|
||||||
|
// 0 = reference clock, 1 = processor clock
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Pos 2 /*!< SysTick CTRL: CLKSOURCE Position */
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
|
||||||
|
// generate interrupt on 0
|
||||||
|
#define SysTick_CTRL_TICKINT_Pos 1 /*!< SysTick CTRL: TICKINT Position */
|
||||||
|
#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
|
||||||
|
// enable counter
|
||||||
|
#define SysTick_CTRL_ENABLE_Pos 0 /*!< SysTick CTRL: ENABLE Position */
|
||||||
|
#define SysTick_CTRL_ENABLE_Msk (1UL << SysTick_CTRL_ENABLE_Pos) /*!< SysTick CTRL: ENABLE Mask */
|
||||||
|
|
||||||
|
/* SysTick Reload Register Definitions */
|
||||||
|
#define SysTick_LOAD_RELOAD_Pos 0 /*!< SysTick LOAD: RELOAD Position */
|
||||||
|
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos) /*!< SysTick LOAD: RELOAD Mask */
|
||||||
|
|
||||||
|
/* SysTick Current Register Definitions */
|
||||||
|
#define SysTick_VAL_CURRENT_Pos 0 /*!< SysTick VAL: CURRENT Position */
|
||||||
|
#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) /*!< SysTick VAL: CURRENT Mask */
|
||||||
|
|
||||||
|
/* SysTick Calibration Register Definitions */
|
||||||
|
#define SysTick_CALIB_NOREF_Pos 31 /*!< SysTick CALIB: NOREF Position */
|
||||||
|
#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_SKEW_Pos 30 /*!< SysTick CALIB: SKEW Position */
|
||||||
|
#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_TENMS_Pos 0 /*!< SysTick CALIB: TENMS Position */
|
||||||
|
#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL << SysTick_CALIB_TENMS_Pos) /*!< SysTick CALIB: TENMS Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SysTick */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
|
||||||
|
\brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR)
|
||||||
|
are only accessible over DAP and not via processor. Therefore
|
||||||
|
they are not covered by the Cortex-M0 header file.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
/*@} end of group CMSIS_CoreDebug */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_core_base Core Definitions
|
||||||
|
\brief Definitions for base addresses, unions, and structures.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Memory mapping of Cortex-M0 Hardware */
|
||||||
|
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
|
||||||
|
#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
|
||||||
|
#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
|
||||||
|
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
|
||||||
|
|
||||||
|
#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
|
||||||
|
#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
|
||||||
|
#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
|
||||||
|
|
||||||
|
|
||||||
|
/*@} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Hardware Abstraction Layer
|
||||||
|
Core Function Interface contains:
|
||||||
|
- Core NVIC Functions
|
||||||
|
- Core SysTick Functions
|
||||||
|
- Core Register Access Functions
|
||||||
|
******************************************************************************/
|
||||||
|
/** \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ########################## NVIC functions #################################### */
|
||||||
|
/** \ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_NVICFunctions NVIC Functions
|
||||||
|
\brief Functions that manage interrupts and exceptions via the NVIC.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Interrupt Priorities are WORD accessible only under ARMv6M */
|
||||||
|
/* The following MACROS handle generation of the register offset and byte masks */
|
||||||
|
#define _BIT_SHIFT(IRQn) ( (((uint32_t)(IRQn) ) & 0x03) * 8 )
|
||||||
|
#define _SHP_IDX(IRQn) ( ((((uint32_t)(IRQn) & 0x0F)-8) >> 2) )
|
||||||
|
#define _IP_IDX(IRQn) ( ((uint32_t)(IRQn) >> 2) )
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Enable External Interrupt
|
||||||
|
|
||||||
|
The function enables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Disable External Interrupt
|
||||||
|
|
||||||
|
The function disables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Pending Interrupt
|
||||||
|
|
||||||
|
The function reads the pending register in the NVIC and returns the pending bit
|
||||||
|
for the specified interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
|
||||||
|
\return 0 Interrupt status is not pending.
|
||||||
|
\return 1 Interrupt status is pending.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
return((uint32_t) ((NVIC->ISPR[0] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Pending Interrupt
|
||||||
|
|
||||||
|
The function sets the pending bit of an external interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Clear Pending Interrupt
|
||||||
|
|
||||||
|
The function clears the pending bit of an external interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Interrupt Priority
|
||||||
|
|
||||||
|
The function sets the priority of an interrupt.
|
||||||
|
|
||||||
|
\note The priority cannot be set for every core interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\param [in] priority Priority to set.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
||||||
|
{
|
||||||
|
if(IRQn < 0) {
|
||||||
|
SCB->SHP[_SHP_IDX(IRQn)] = (SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8 - __NVIC_PRIO_BITS)) & 0xFF) << _BIT_SHIFT(IRQn)); }
|
||||||
|
else {
|
||||||
|
NVIC->IP[_IP_IDX(IRQn)] = (NVIC->IP[_IP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8 - __NVIC_PRIO_BITS)) & 0xFF) << _BIT_SHIFT(IRQn)); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Interrupt Priority
|
||||||
|
|
||||||
|
The function reads the priority of an interrupt. The interrupt
|
||||||
|
number can be positive to specify an external (device specific)
|
||||||
|
interrupt, or negative to specify an internal (core) interrupt.
|
||||||
|
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\return Interrupt Priority. Value is aligned automatically to the implemented
|
||||||
|
priority bits of the microcontroller.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(IRQn < 0) {
|
||||||
|
return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M0 system interrupts */
|
||||||
|
else {
|
||||||
|
return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief System Reset
|
||||||
|
|
||||||
|
The function initiates a system reset request to reset the MCU.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SystemReset(void)
|
||||||
|
{
|
||||||
|
__DSB(); /* Ensure all outstanding memory accesses included
|
||||||
|
buffered write are completed before reset */
|
||||||
|
SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
|
||||||
|
SCB_AIRCR_SYSRESETREQ_Msk);
|
||||||
|
__DSB(); /* Ensure completion of memory access */
|
||||||
|
while(1); /* wait until reset */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_NVICFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ################################## SysTick function ############################################ */
|
||||||
|
/** \ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_SysTickFunctions SysTick Functions
|
||||||
|
\brief Functions that configure the System.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (__Vendor_SysTickConfig == 0)
|
||||||
|
|
||||||
|
/** \brief System Tick Configuration
|
||||||
|
|
||||||
|
The function initializes the System Timer and its interrupt, and starts the System Tick Timer.
|
||||||
|
Counter is in free running mode to generate periodic interrupts.
|
||||||
|
|
||||||
|
\param [in] ticks Number of ticks between two interrupts.
|
||||||
|
\param [in] div8 Does systick run directly from source (0) or from F/8 (1)
|
||||||
|
|
||||||
|
\return 0 Function succeeded.
|
||||||
|
\return 1 Function failed.
|
||||||
|
|
||||||
|
\note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
|
||||||
|
function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
|
||||||
|
must contain a vendor-specific implementation of this function.
|
||||||
|
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks, uint32_t div8)
|
||||||
|
{
|
||||||
|
if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
|
||||||
|
|
||||||
|
SysTick->LOAD = ticks - 1; /* set reload register */
|
||||||
|
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
|
||||||
|
SysTick->VAL = 0; /* Load the SysTick Counter Value */
|
||||||
|
SysTick->CTRL = SysTick_CTRL_TICKINT_Msk |
|
||||||
|
SysTick_CTRL_ENABLE_Msk;
|
||||||
|
if(!div8) SysTick->CTRL |= SysTick_CTRL_CLKSOURCE_Msk;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_SysTickFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_CM0_H_DEPENDANT */
|
||||||
|
|
||||||
|
#endif /* __CMSIS_GENERIC */
|
||||||
822
F1-nolib/inc/cm/core_cm0plus.h
Normal file
822
F1-nolib/inc/cm/core_cm0plus.h
Normal file
@ -0,0 +1,822 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_cm0plus.h
|
||||||
|
* @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File
|
||||||
|
* @version V4.00
|
||||||
|
* @date 22. August 2014
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2014 ARM LIMITED
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
- Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CORE_CM0PLUS_H_GENERIC
|
||||||
|
#define __CORE_CM0PLUS_H_GENERIC
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
|
||||||
|
CMSIS violates the following MISRA-C:2004 rules:
|
||||||
|
|
||||||
|
\li Required Rule 8.5, object/function definition in header file.<br>
|
||||||
|
Function definitions in header files are used to allow 'inlining'.
|
||||||
|
|
||||||
|
\li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
|
||||||
|
Unions are used for effective representation of core registers.
|
||||||
|
|
||||||
|
\li Advisory Rule 19.7, Function-like macro defined.<br>
|
||||||
|
Function-like macros are used to allow more efficient code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* CMSIS definitions
|
||||||
|
******************************************************************************/
|
||||||
|
/** \ingroup Cortex-M0+
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* CMSIS CM0P definitions */
|
||||||
|
#define __CM0PLUS_CMSIS_VERSION_MAIN (0x04) /*!< [31:16] CMSIS HAL main version */
|
||||||
|
#define __CM0PLUS_CMSIS_VERSION_SUB (0x00) /*!< [15:0] CMSIS HAL sub version */
|
||||||
|
#define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16) | \
|
||||||
|
__CM0PLUS_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number */
|
||||||
|
|
||||||
|
#define __CORTEX_M (0x00) /*!< Cortex-M Core */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#define __ASM __asm /*!< asm keyword for ARM Compiler */
|
||||||
|
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
|
||||||
|
#define __STATIC_INLINE static __inline
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for GNU Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for GNU Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for IAR Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TI CCS Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for TASKING Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#define __packed
|
||||||
|
#define __ASM _asm /*!< asm keyword for COSMIC Compiler */
|
||||||
|
#define __INLINE inline /*use -pc99 on compile line !< inline keyword for COSMIC Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** __FPU_USED indicates whether an FPU is used or not.
|
||||||
|
This core does not support an FPU at all
|
||||||
|
*/
|
||||||
|
#define __FPU_USED 0
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#if defined __TARGET_FPU_VFP
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#if defined __ARMVFP__
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#if defined __TI__VFP_SUPPORT____
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#if defined __FPU_VFP__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ ) /* Cosmic */
|
||||||
|
#if ( __CSMC__ & 0x400) // FPU present for parser
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h> /* standard types definitions */
|
||||||
|
#include <core_cmInstr.h> /* Core Instruction Access */
|
||||||
|
#include <core_cmFunc.h> /* Core Function Access */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_CM0PLUS_H_GENERIC */
|
||||||
|
|
||||||
|
#ifndef __CMSIS_GENERIC
|
||||||
|
|
||||||
|
#ifndef __CORE_CM0PLUS_H_DEPENDANT
|
||||||
|
#define __CORE_CM0PLUS_H_DEPENDANT
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* check device defines and use defaults */
|
||||||
|
#if defined __CHECK_DEVICE_DEFINES
|
||||||
|
#ifndef __CM0PLUS_REV
|
||||||
|
#define __CM0PLUS_REV 0x0000
|
||||||
|
#warning "__CM0PLUS_REV not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __MPU_PRESENT
|
||||||
|
#define __MPU_PRESENT 0
|
||||||
|
#warning "__MPU_PRESENT not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __VTOR_PRESENT
|
||||||
|
#define __VTOR_PRESENT 0
|
||||||
|
#warning "__VTOR_PRESENT not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __NVIC_PRIO_BITS
|
||||||
|
#define __NVIC_PRIO_BITS 2
|
||||||
|
#warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __Vendor_SysTickConfig
|
||||||
|
#define __Vendor_SysTickConfig 0
|
||||||
|
#warning "__Vendor_SysTickConfig not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* IO definitions (access restrictions to peripheral registers) */
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_glob_defs CMSIS Global Defines
|
||||||
|
|
||||||
|
<strong>IO Type Qualifiers</strong> are used
|
||||||
|
\li to specify the access to peripheral variables.
|
||||||
|
\li for automatic generation of peripheral register debug information.
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define __I volatile /*!< Defines 'read only' permissions */
|
||||||
|
#else
|
||||||
|
#define __I volatile const /*!< Defines 'read only' permissions */
|
||||||
|
#endif
|
||||||
|
#define __O volatile /*!< Defines 'write only' permissions */
|
||||||
|
#define __IO volatile /*!< Defines 'read / write' permissions */
|
||||||
|
|
||||||
|
/*@} end of group Cortex-M0+ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Register Abstraction
|
||||||
|
Core Register contain:
|
||||||
|
- Core Register
|
||||||
|
- Core NVIC Register
|
||||||
|
- Core SCB Register
|
||||||
|
- Core SysTick Register
|
||||||
|
- Core MPU Register
|
||||||
|
******************************************************************************/
|
||||||
|
/** \defgroup CMSIS_core_register Defines and Type Definitions
|
||||||
|
\brief Type definitions and defines for Cortex-M processor based devices.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CORE Status and Control Registers
|
||||||
|
\brief Core Register type definitions.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Union type to access the Application Program Status Register (APSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
#if (__CORTEX_M != 0x04)
|
||||||
|
uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */
|
||||||
|
#else
|
||||||
|
uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */
|
||||||
|
uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
|
||||||
|
uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */
|
||||||
|
#endif
|
||||||
|
uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} APSR_Type;
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Union type to access the Interrupt Program Status Register (IPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} IPSR_Type;
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Union type to access the Special-Purpose Program Status Registers (xPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
#if (__CORTEX_M != 0x04)
|
||||||
|
uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
|
||||||
|
#else
|
||||||
|
uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */
|
||||||
|
uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
|
||||||
|
uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */
|
||||||
|
#endif
|
||||||
|
uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
|
||||||
|
uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */
|
||||||
|
uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} xPSR_Type;
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Union type to access the Control Registers (CONTROL).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */
|
||||||
|
uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
|
||||||
|
uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */
|
||||||
|
uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} CONTROL_Type;
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_CORE */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
|
||||||
|
\brief Type definitions for the NVIC Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IO uint32_t ISER[1]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
|
||||||
|
uint32_t RESERVED0[31];
|
||||||
|
__IO uint32_t ICER[1]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
|
||||||
|
uint32_t RSERVED1[31];
|
||||||
|
__IO uint32_t ISPR[1]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
|
||||||
|
uint32_t RESERVED2[31];
|
||||||
|
__IO uint32_t ICPR[1]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
|
||||||
|
uint32_t RESERVED3[31];
|
||||||
|
uint32_t RESERVED4[64];
|
||||||
|
__IO uint32_t IP[8]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
|
||||||
|
} NVIC_Type;
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_NVIC */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SCB System Control Block (SCB)
|
||||||
|
\brief Type definitions for the System Control Block Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the System Control Block (SCB).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__I uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
|
||||||
|
__IO uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
|
||||||
|
#if (__VTOR_PRESENT == 1)
|
||||||
|
__IO uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */
|
||||||
|
#else
|
||||||
|
uint32_t RESERVED0;
|
||||||
|
#endif
|
||||||
|
__IO uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
|
||||||
|
__IO uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
|
||||||
|
__IO uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
|
||||||
|
uint32_t RESERVED1;
|
||||||
|
__IO uint32_t SHP[2]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
|
||||||
|
__IO uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
|
||||||
|
} SCB_Type;
|
||||||
|
|
||||||
|
/* SCB CPUID Register Definitions */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Pos 24 /*!< SCB CPUID: IMPLEMENTER Position */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_VARIANT_Pos 20 /*!< SCB CPUID: VARIANT Position */
|
||||||
|
#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Pos 16 /*!< SCB CPUID: ARCHITECTURE Position */
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_PARTNO_Pos 4 /*!< SCB CPUID: PARTNO Position */
|
||||||
|
#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_REVISION_Pos 0 /*!< SCB CPUID: REVISION Position */
|
||||||
|
#define SCB_CPUID_REVISION_Msk (0xFUL << SCB_CPUID_REVISION_Pos) /*!< SCB CPUID: REVISION Mask */
|
||||||
|
|
||||||
|
/* SCB Interrupt Control State Register Definitions */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Pos 31 /*!< SCB ICSR: NMIPENDSET Position */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVSET_Pos 28 /*!< SCB ICSR: PENDSVSET Position */
|
||||||
|
#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Pos 27 /*!< SCB ICSR: PENDSVCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTSET_Pos 26 /*!< SCB ICSR: PENDSTSET Position */
|
||||||
|
#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Pos 25 /*!< SCB ICSR: PENDSTCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Pos 23 /*!< SCB ICSR: ISRPREEMPT Position */
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPENDING_Pos 22 /*!< SCB ICSR: ISRPENDING Position */
|
||||||
|
#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTPENDING_Pos 12 /*!< SCB ICSR: VECTPENDING Position */
|
||||||
|
#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Pos 0 /*!< SCB ICSR: VECTACTIVE Position */
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos) /*!< SCB ICSR: VECTACTIVE Mask */
|
||||||
|
|
||||||
|
#if (__VTOR_PRESENT == 1)
|
||||||
|
/* SCB Interrupt Control State Register Definitions */
|
||||||
|
#define SCB_VTOR_TBLOFF_Pos 8 /*!< SCB VTOR: TBLOFF Position */
|
||||||
|
#define SCB_VTOR_TBLOFF_Msk (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* SCB Application Interrupt and Reset Control Register Definitions */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Pos 16 /*!< SCB AIRCR: VECTKEY Position */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Pos 16 /*!< SCB AIRCR: VECTKEYSTAT Position */
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Pos 15 /*!< SCB AIRCR: ENDIANESS Position */
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Pos 2 /*!< SCB AIRCR: SYSRESETREQ Position */
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Pos 1 /*!< SCB AIRCR: VECTCLRACTIVE Position */
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
|
||||||
|
|
||||||
|
/* SCB System Control Register Definitions */
|
||||||
|
#define SCB_SCR_SEVONPEND_Pos 4 /*!< SCB SCR: SEVONPEND Position */
|
||||||
|
#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Pos 2 /*!< SCB SCR: SLEEPDEEP Position */
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Pos 1 /*!< SCB SCR: SLEEPONEXIT Position */
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
|
||||||
|
|
||||||
|
/* SCB Configuration Control Register Definitions */
|
||||||
|
#define SCB_CCR_STKALIGN_Pos 9 /*!< SCB CCR: STKALIGN Position */
|
||||||
|
#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
|
||||||
|
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Pos 3 /*!< SCB CCR: UNALIGN_TRP Position */
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
|
||||||
|
|
||||||
|
/* SCB System Handler Control and State Register Definitions */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Pos 15 /*!< SCB SHCSR: SVCALLPENDED Position */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SCB */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SysTick System Tick Timer (SysTick)
|
||||||
|
\brief Type definitions for the System Timer Registers.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the System Timer (SysTick).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IO uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
|
||||||
|
__IO uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
|
||||||
|
__IO uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
|
||||||
|
__I uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
|
||||||
|
} SysTick_Type;
|
||||||
|
|
||||||
|
/* SysTick Control / Status Register Definitions */
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Pos 16 /*!< SysTick CTRL: COUNTFLAG Position */
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Pos 2 /*!< SysTick CTRL: CLKSOURCE Position */
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_TICKINT_Pos 1 /*!< SysTick CTRL: TICKINT Position */
|
||||||
|
#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_ENABLE_Pos 0 /*!< SysTick CTRL: ENABLE Position */
|
||||||
|
#define SysTick_CTRL_ENABLE_Msk (1UL << SysTick_CTRL_ENABLE_Pos) /*!< SysTick CTRL: ENABLE Mask */
|
||||||
|
|
||||||
|
/* SysTick Reload Register Definitions */
|
||||||
|
#define SysTick_LOAD_RELOAD_Pos 0 /*!< SysTick LOAD: RELOAD Position */
|
||||||
|
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos) /*!< SysTick LOAD: RELOAD Mask */
|
||||||
|
|
||||||
|
/* SysTick Current Register Definitions */
|
||||||
|
#define SysTick_VAL_CURRENT_Pos 0 /*!< SysTick VAL: CURRENT Position */
|
||||||
|
#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) /*!< SysTick VAL: CURRENT Mask */
|
||||||
|
|
||||||
|
/* SysTick Calibration Register Definitions */
|
||||||
|
#define SysTick_CALIB_NOREF_Pos 31 /*!< SysTick CALIB: NOREF Position */
|
||||||
|
#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_SKEW_Pos 30 /*!< SysTick CALIB: SKEW Position */
|
||||||
|
#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_TENMS_Pos 0 /*!< SysTick CALIB: TENMS Position */
|
||||||
|
#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL << SysTick_CALIB_TENMS_Pos) /*!< SysTick CALIB: TENMS Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SysTick */
|
||||||
|
|
||||||
|
#if (__MPU_PRESENT == 1)
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_MPU Memory Protection Unit (MPU)
|
||||||
|
\brief Type definitions for the Memory Protection Unit (MPU)
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the Memory Protection Unit (MPU).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__I uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */
|
||||||
|
__IO uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */
|
||||||
|
__IO uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */
|
||||||
|
__IO uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */
|
||||||
|
__IO uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */
|
||||||
|
} MPU_Type;
|
||||||
|
|
||||||
|
/* MPU Type Register */
|
||||||
|
#define MPU_TYPE_IREGION_Pos 16 /*!< MPU TYPE: IREGION Position */
|
||||||
|
#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */
|
||||||
|
|
||||||
|
#define MPU_TYPE_DREGION_Pos 8 /*!< MPU TYPE: DREGION Position */
|
||||||
|
#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */
|
||||||
|
|
||||||
|
#define MPU_TYPE_SEPARATE_Pos 0 /*!< MPU TYPE: SEPARATE Position */
|
||||||
|
#define MPU_TYPE_SEPARATE_Msk (1UL << MPU_TYPE_SEPARATE_Pos) /*!< MPU TYPE: SEPARATE Mask */
|
||||||
|
|
||||||
|
/* MPU Control Register */
|
||||||
|
#define MPU_CTRL_PRIVDEFENA_Pos 2 /*!< MPU CTRL: PRIVDEFENA Position */
|
||||||
|
#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */
|
||||||
|
|
||||||
|
#define MPU_CTRL_HFNMIENA_Pos 1 /*!< MPU CTRL: HFNMIENA Position */
|
||||||
|
#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */
|
||||||
|
|
||||||
|
#define MPU_CTRL_ENABLE_Pos 0 /*!< MPU CTRL: ENABLE Position */
|
||||||
|
#define MPU_CTRL_ENABLE_Msk (1UL << MPU_CTRL_ENABLE_Pos) /*!< MPU CTRL: ENABLE Mask */
|
||||||
|
|
||||||
|
/* MPU Region Number Register */
|
||||||
|
#define MPU_RNR_REGION_Pos 0 /*!< MPU RNR: REGION Position */
|
||||||
|
#define MPU_RNR_REGION_Msk (0xFFUL << MPU_RNR_REGION_Pos) /*!< MPU RNR: REGION Mask */
|
||||||
|
|
||||||
|
/* MPU Region Base Address Register */
|
||||||
|
#define MPU_RBAR_ADDR_Pos 8 /*!< MPU RBAR: ADDR Position */
|
||||||
|
#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */
|
||||||
|
|
||||||
|
#define MPU_RBAR_VALID_Pos 4 /*!< MPU RBAR: VALID Position */
|
||||||
|
#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */
|
||||||
|
|
||||||
|
#define MPU_RBAR_REGION_Pos 0 /*!< MPU RBAR: REGION Position */
|
||||||
|
#define MPU_RBAR_REGION_Msk (0xFUL << MPU_RBAR_REGION_Pos) /*!< MPU RBAR: REGION Mask */
|
||||||
|
|
||||||
|
/* MPU Region Attribute and Size Register */
|
||||||
|
#define MPU_RASR_ATTRS_Pos 16 /*!< MPU RASR: MPU Region Attribute field Position */
|
||||||
|
#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_XN_Pos 28 /*!< MPU RASR: ATTRS.XN Position */
|
||||||
|
#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_AP_Pos 24 /*!< MPU RASR: ATTRS.AP Position */
|
||||||
|
#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_TEX_Pos 19 /*!< MPU RASR: ATTRS.TEX Position */
|
||||||
|
#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_S_Pos 18 /*!< MPU RASR: ATTRS.S Position */
|
||||||
|
#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_C_Pos 17 /*!< MPU RASR: ATTRS.C Position */
|
||||||
|
#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_B_Pos 16 /*!< MPU RASR: ATTRS.B Position */
|
||||||
|
#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_SRD_Pos 8 /*!< MPU RASR: Sub-Region Disable Position */
|
||||||
|
#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_SIZE_Pos 1 /*!< MPU RASR: Region Size Field Position */
|
||||||
|
#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_ENABLE_Pos 0 /*!< MPU RASR: Region enable bit Position */
|
||||||
|
#define MPU_RASR_ENABLE_Msk (1UL << MPU_RASR_ENABLE_Pos) /*!< MPU RASR: Region enable bit Disable Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_MPU */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
|
||||||
|
\brief Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR)
|
||||||
|
are only accessible over DAP and not via processor. Therefore
|
||||||
|
they are not covered by the Cortex-M0 header file.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
/*@} end of group CMSIS_CoreDebug */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_core_base Core Definitions
|
||||||
|
\brief Definitions for base addresses, unions, and structures.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Memory mapping of Cortex-M0+ Hardware */
|
||||||
|
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
|
||||||
|
#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
|
||||||
|
#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
|
||||||
|
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
|
||||||
|
|
||||||
|
#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
|
||||||
|
#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
|
||||||
|
#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
|
||||||
|
|
||||||
|
#if (__MPU_PRESENT == 1)
|
||||||
|
#define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */
|
||||||
|
#define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Hardware Abstraction Layer
|
||||||
|
Core Function Interface contains:
|
||||||
|
- Core NVIC Functions
|
||||||
|
- Core SysTick Functions
|
||||||
|
- Core Register Access Functions
|
||||||
|
******************************************************************************/
|
||||||
|
/** \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ########################## NVIC functions #################################### */
|
||||||
|
/** \ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_NVICFunctions NVIC Functions
|
||||||
|
\brief Functions that manage interrupts and exceptions via the NVIC.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Interrupt Priorities are WORD accessible only under ARMv6M */
|
||||||
|
/* The following MACROS handle generation of the register offset and byte masks */
|
||||||
|
#define _BIT_SHIFT(IRQn) ( (((uint32_t)(IRQn) ) & 0x03) * 8 )
|
||||||
|
#define _SHP_IDX(IRQn) ( ((((uint32_t)(IRQn) & 0x0F)-8) >> 2) )
|
||||||
|
#define _IP_IDX(IRQn) ( ((uint32_t)(IRQn) >> 2) )
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Enable External Interrupt
|
||||||
|
|
||||||
|
The function enables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Disable External Interrupt
|
||||||
|
|
||||||
|
The function disables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Pending Interrupt
|
||||||
|
|
||||||
|
The function reads the pending register in the NVIC and returns the pending bit
|
||||||
|
for the specified interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
|
||||||
|
\return 0 Interrupt status is not pending.
|
||||||
|
\return 1 Interrupt status is pending.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
return((uint32_t) ((NVIC->ISPR[0] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Pending Interrupt
|
||||||
|
|
||||||
|
The function sets the pending bit of an external interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Clear Pending Interrupt
|
||||||
|
|
||||||
|
The function clears the pending bit of an external interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Interrupt Priority
|
||||||
|
|
||||||
|
The function sets the priority of an interrupt.
|
||||||
|
|
||||||
|
\note The priority cannot be set for every core interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\param [in] priority Priority to set.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
||||||
|
{
|
||||||
|
if(IRQn < 0) {
|
||||||
|
SCB->SHP[_SHP_IDX(IRQn)] = (SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8 - __NVIC_PRIO_BITS)) & 0xFF) << _BIT_SHIFT(IRQn)); }
|
||||||
|
else {
|
||||||
|
NVIC->IP[_IP_IDX(IRQn)] = (NVIC->IP[_IP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8 - __NVIC_PRIO_BITS)) & 0xFF) << _BIT_SHIFT(IRQn)); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Interrupt Priority
|
||||||
|
|
||||||
|
The function reads the priority of an interrupt. The interrupt
|
||||||
|
number can be positive to specify an external (device specific)
|
||||||
|
interrupt, or negative to specify an internal (core) interrupt.
|
||||||
|
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\return Interrupt Priority. Value is aligned automatically to the implemented
|
||||||
|
priority bits of the microcontroller.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(IRQn < 0) {
|
||||||
|
return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M0 system interrupts */
|
||||||
|
else {
|
||||||
|
return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief System Reset
|
||||||
|
|
||||||
|
The function initiates a system reset request to reset the MCU.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SystemReset(void)
|
||||||
|
{
|
||||||
|
__DSB(); /* Ensure all outstanding memory accesses included
|
||||||
|
buffered write are completed before reset */
|
||||||
|
SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
|
||||||
|
SCB_AIRCR_SYSRESETREQ_Msk);
|
||||||
|
__DSB(); /* Ensure completion of memory access */
|
||||||
|
while(1); /* wait until reset */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_NVICFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ################################## SysTick function ############################################ */
|
||||||
|
/** \ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_SysTickFunctions SysTick Functions
|
||||||
|
\brief Functions that configure the System.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (__Vendor_SysTickConfig == 0)
|
||||||
|
|
||||||
|
/** \brief System Tick Configuration
|
||||||
|
|
||||||
|
The function initializes the System Timer and its interrupt, and starts the System Tick Timer.
|
||||||
|
Counter is in free running mode to generate periodic interrupts.
|
||||||
|
|
||||||
|
\param [in] ticks Number of ticks between two interrupts.
|
||||||
|
|
||||||
|
\return 0 Function succeeded.
|
||||||
|
\return 1 Function failed.
|
||||||
|
|
||||||
|
\note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
|
||||||
|
function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
|
||||||
|
must contain a vendor-specific implementation of this function.
|
||||||
|
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
|
||||||
|
{
|
||||||
|
if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
|
||||||
|
|
||||||
|
SysTick->LOAD = ticks - 1; /* set reload register */
|
||||||
|
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
|
||||||
|
SysTick->VAL = 0; /* Load the SysTick Counter Value */
|
||||||
|
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
|
||||||
|
SysTick_CTRL_TICKINT_Msk |
|
||||||
|
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
|
||||||
|
return (0); /* Function successful */
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_SysTickFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_CM0PLUS_H_DEPENDANT */
|
||||||
|
|
||||||
|
#endif /* __CMSIS_GENERIC */
|
||||||
1650
F1-nolib/inc/cm/core_cm3.h
Normal file
1650
F1-nolib/inc/cm/core_cm3.h
Normal file
File diff suppressed because it is too large
Load Diff
1802
F1-nolib/inc/cm/core_cm4.h
Normal file
1802
F1-nolib/inc/cm/core_cm4.h
Normal file
File diff suppressed because it is too large
Load Diff
2221
F1-nolib/inc/cm/core_cm7.h
Normal file
2221
F1-nolib/inc/cm/core_cm7.h
Normal file
File diff suppressed because it is too large
Load Diff
637
F1-nolib/inc/cm/core_cmFunc.h
Normal file
637
F1-nolib/inc/cm/core_cmFunc.h
Normal file
@ -0,0 +1,637 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_cmFunc.h
|
||||||
|
* @brief CMSIS Cortex-M Core Function Access Header File
|
||||||
|
* @version V4.00
|
||||||
|
* @date 28. August 2014
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2014 ARM LIMITED
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
- Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __CORE_CMFUNC_H
|
||||||
|
#define __CORE_CMFUNC_H
|
||||||
|
|
||||||
|
|
||||||
|
/* ########################### Core Function Access ########################### */
|
||||||
|
/** \ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
|
||||||
|
/* ARM armcc specific functions */
|
||||||
|
|
||||||
|
#if (__ARMCC_VERSION < 400677)
|
||||||
|
#error "Please use ARM Compiler Toolchain V4.0.677 or later!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* intrinsic void __enable_irq(); */
|
||||||
|
/* intrinsic void __disable_irq(); */
|
||||||
|
|
||||||
|
/** \brief Get Control Register
|
||||||
|
|
||||||
|
This function returns the content of the Control Register.
|
||||||
|
|
||||||
|
\return Control Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_CONTROL(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regControl __ASM("control");
|
||||||
|
return(__regControl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Control Register
|
||||||
|
|
||||||
|
This function writes the given value to the Control Register.
|
||||||
|
|
||||||
|
\param [in] control Control Register value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_CONTROL(uint32_t control)
|
||||||
|
{
|
||||||
|
register uint32_t __regControl __ASM("control");
|
||||||
|
__regControl = control;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get IPSR Register
|
||||||
|
|
||||||
|
This function returns the content of the IPSR Register.
|
||||||
|
|
||||||
|
\return IPSR Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_IPSR(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regIPSR __ASM("ipsr");
|
||||||
|
return(__regIPSR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get APSR Register
|
||||||
|
|
||||||
|
This function returns the content of the APSR Register.
|
||||||
|
|
||||||
|
\return APSR Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_APSR(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regAPSR __ASM("apsr");
|
||||||
|
return(__regAPSR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get xPSR Register
|
||||||
|
|
||||||
|
This function returns the content of the xPSR Register.
|
||||||
|
|
||||||
|
\return xPSR Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_xPSR(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regXPSR __ASM("xpsr");
|
||||||
|
return(__regXPSR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Process Stack Pointer
|
||||||
|
|
||||||
|
This function returns the current value of the Process Stack Pointer (PSP).
|
||||||
|
|
||||||
|
\return PSP Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_PSP(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||||
|
return(__regProcessStackPointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Process Stack Pointer
|
||||||
|
|
||||||
|
This function assigns the given value to the Process Stack Pointer (PSP).
|
||||||
|
|
||||||
|
\param [in] topOfProcStack Process Stack Pointer value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
|
||||||
|
{
|
||||||
|
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||||
|
__regProcessStackPointer = topOfProcStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Main Stack Pointer
|
||||||
|
|
||||||
|
This function returns the current value of the Main Stack Pointer (MSP).
|
||||||
|
|
||||||
|
\return MSP Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_MSP(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regMainStackPointer __ASM("msp");
|
||||||
|
return(__regMainStackPointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Main Stack Pointer
|
||||||
|
|
||||||
|
This function assigns the given value to the Main Stack Pointer (MSP).
|
||||||
|
|
||||||
|
\param [in] topOfMainStack Main Stack Pointer value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
|
||||||
|
{
|
||||||
|
register uint32_t __regMainStackPointer __ASM("msp");
|
||||||
|
__regMainStackPointer = topOfMainStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Priority Mask
|
||||||
|
|
||||||
|
This function returns the current state of the priority mask bit from the Priority Mask Register.
|
||||||
|
|
||||||
|
\return Priority Mask value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_PRIMASK(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regPriMask __ASM("primask");
|
||||||
|
return(__regPriMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Priority Mask
|
||||||
|
|
||||||
|
This function assigns the given value to the Priority Mask Register.
|
||||||
|
|
||||||
|
\param [in] priMask Priority Mask
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
|
||||||
|
{
|
||||||
|
register uint32_t __regPriMask __ASM("primask");
|
||||||
|
__regPriMask = (priMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300)
|
||||||
|
|
||||||
|
/** \brief Enable FIQ
|
||||||
|
|
||||||
|
This function enables FIQ interrupts by clearing the F-bit in the CPSR.
|
||||||
|
Can only be executed in Privileged modes.
|
||||||
|
*/
|
||||||
|
#define __enable_fault_irq __enable_fiq
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Disable FIQ
|
||||||
|
|
||||||
|
This function disables FIQ interrupts by setting the F-bit in the CPSR.
|
||||||
|
Can only be executed in Privileged modes.
|
||||||
|
*/
|
||||||
|
#define __disable_fault_irq __disable_fiq
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Base Priority
|
||||||
|
|
||||||
|
This function returns the current value of the Base Priority register.
|
||||||
|
|
||||||
|
\return Base Priority register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_BASEPRI(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regBasePri __ASM("basepri");
|
||||||
|
return(__regBasePri);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Base Priority
|
||||||
|
|
||||||
|
This function assigns the given value to the Base Priority register.
|
||||||
|
|
||||||
|
\param [in] basePri Base Priority value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
|
||||||
|
{
|
||||||
|
register uint32_t __regBasePri __ASM("basepri");
|
||||||
|
__regBasePri = (basePri & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Fault Mask
|
||||||
|
|
||||||
|
This function returns the current value of the Fault Mask register.
|
||||||
|
|
||||||
|
\return Fault Mask register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_FAULTMASK(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regFaultMask __ASM("faultmask");
|
||||||
|
return(__regFaultMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Fault Mask
|
||||||
|
|
||||||
|
This function assigns the given value to the Fault Mask register.
|
||||||
|
|
||||||
|
\param [in] faultMask Fault Mask value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
|
||||||
|
{
|
||||||
|
register uint32_t __regFaultMask __ASM("faultmask");
|
||||||
|
__regFaultMask = (faultMask & (uint32_t)1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300) */
|
||||||
|
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07)
|
||||||
|
|
||||||
|
/** \brief Get FPSCR
|
||||||
|
|
||||||
|
This function returns the current value of the Floating Point Status/Control register.
|
||||||
|
|
||||||
|
\return Floating Point Status/Control register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_FPSCR(void)
|
||||||
|
{
|
||||||
|
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||||
|
register uint32_t __regfpscr __ASM("fpscr");
|
||||||
|
return(__regfpscr);
|
||||||
|
#else
|
||||||
|
return(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set FPSCR
|
||||||
|
|
||||||
|
This function assigns the given value to the Floating Point Status/Control register.
|
||||||
|
|
||||||
|
\param [in] fpscr Floating Point Status/Control value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
|
||||||
|
{
|
||||||
|
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||||
|
register uint32_t __regfpscr __ASM("fpscr");
|
||||||
|
__regfpscr = (fpscr);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07) */
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
|
||||||
|
/* GNU gcc specific functions */
|
||||||
|
|
||||||
|
/** \brief Enable IRQ Interrupts
|
||||||
|
|
||||||
|
This function enables IRQ interrupts by clearing the I-bit in the CPSR.
|
||||||
|
Can only be executed in Privileged modes.
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("cpsie i" : : : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Disable IRQ Interrupts
|
||||||
|
|
||||||
|
This function disables IRQ interrupts by setting the I-bit in the CPSR.
|
||||||
|
Can only be executed in Privileged modes.
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("cpsid i" : : : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Control Register
|
||||||
|
|
||||||
|
This function returns the content of the Control Register.
|
||||||
|
|
||||||
|
\return Control Register value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("MRS %0, control" : "=r" (result) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Control Register
|
||||||
|
|
||||||
|
This function writes the given value to the Control Register.
|
||||||
|
|
||||||
|
\param [in] control Control Register value to set
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control)
|
||||||
|
{
|
||||||
|
__ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get IPSR Register
|
||||||
|
|
||||||
|
This function returns the content of the IPSR Register.
|
||||||
|
|
||||||
|
\return IPSR Register value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("MRS %0, ipsr" : "=r" (result) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get APSR Register
|
||||||
|
|
||||||
|
This function returns the content of the APSR Register.
|
||||||
|
|
||||||
|
\return APSR Register value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("MRS %0, apsr" : "=r" (result) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get xPSR Register
|
||||||
|
|
||||||
|
This function returns the content of the xPSR Register.
|
||||||
|
|
||||||
|
\return xPSR Register value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("MRS %0, xpsr" : "=r" (result) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Process Stack Pointer
|
||||||
|
|
||||||
|
This function returns the current value of the Process Stack Pointer (PSP).
|
||||||
|
|
||||||
|
\return PSP Register value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void)
|
||||||
|
{
|
||||||
|
register uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("MRS %0, psp\n" : "=r" (result) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Process Stack Pointer
|
||||||
|
|
||||||
|
This function assigns the given value to the Process Stack Pointer (PSP).
|
||||||
|
|
||||||
|
\param [in] topOfProcStack Process Stack Pointer value to set
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
|
||||||
|
{
|
||||||
|
__ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Main Stack Pointer
|
||||||
|
|
||||||
|
This function returns the current value of the Main Stack Pointer (MSP).
|
||||||
|
|
||||||
|
\return MSP Register value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void)
|
||||||
|
{
|
||||||
|
register uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("MRS %0, msp\n" : "=r" (result) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Main Stack Pointer
|
||||||
|
|
||||||
|
This function assigns the given value to the Main Stack Pointer (MSP).
|
||||||
|
|
||||||
|
\param [in] topOfMainStack Main Stack Pointer value to set
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
|
||||||
|
{
|
||||||
|
__ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Priority Mask
|
||||||
|
|
||||||
|
This function returns the current state of the priority mask bit from the Priority Mask Register.
|
||||||
|
|
||||||
|
\return Priority Mask value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("MRS %0, primask" : "=r" (result) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Priority Mask
|
||||||
|
|
||||||
|
This function assigns the given value to the Priority Mask Register.
|
||||||
|
|
||||||
|
\param [in] priMask Priority Mask
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
|
||||||
|
{
|
||||||
|
__ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if (__CORTEX_M >= 0x03)
|
||||||
|
|
||||||
|
/** \brief Enable FIQ
|
||||||
|
|
||||||
|
This function enables FIQ interrupts by clearing the F-bit in the CPSR.
|
||||||
|
Can only be executed in Privileged modes.
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("cpsie f" : : : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Disable FIQ
|
||||||
|
|
||||||
|
This function disables FIQ interrupts by setting the F-bit in the CPSR.
|
||||||
|
Can only be executed in Privileged modes.
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("cpsid f" : : : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Base Priority
|
||||||
|
|
||||||
|
This function returns the current value of the Base Priority register.
|
||||||
|
|
||||||
|
\return Base Priority register value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("MRS %0, basepri_max" : "=r" (result) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Base Priority
|
||||||
|
|
||||||
|
This function assigns the given value to the Base Priority register.
|
||||||
|
|
||||||
|
\param [in] basePri Base Priority value to set
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value)
|
||||||
|
{
|
||||||
|
__ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Fault Mask
|
||||||
|
|
||||||
|
This function returns the current value of the Fault Mask register.
|
||||||
|
|
||||||
|
\return Fault Mask register value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("MRS %0, faultmask" : "=r" (result) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Fault Mask
|
||||||
|
|
||||||
|
This function assigns the given value to the Fault Mask register.
|
||||||
|
|
||||||
|
\param [in] faultMask Fault Mask value to set
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
|
||||||
|
{
|
||||||
|
__ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* (__CORTEX_M >= 0x03) */
|
||||||
|
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07)
|
||||||
|
|
||||||
|
/** \brief Get FPSCR
|
||||||
|
|
||||||
|
This function returns the current value of the Floating Point Status/Control register.
|
||||||
|
|
||||||
|
\return Floating Point Status/Control register value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void)
|
||||||
|
{
|
||||||
|
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
/* Empty asm statement works as a scheduling barrier */
|
||||||
|
__ASM volatile ("");
|
||||||
|
__ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
|
||||||
|
__ASM volatile ("");
|
||||||
|
return(result);
|
||||||
|
#else
|
||||||
|
return(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set FPSCR
|
||||||
|
|
||||||
|
This function assigns the given value to the Floating Point Status/Control register.
|
||||||
|
|
||||||
|
\param [in] fpscr Floating Point Status/Control value to set
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
|
||||||
|
{
|
||||||
|
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||||
|
/* Empty asm statement works as a scheduling barrier */
|
||||||
|
__ASM volatile ("");
|
||||||
|
__ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc");
|
||||||
|
__ASM volatile ("");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07) */
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
|
||||||
|
/* IAR iccarm specific functions */
|
||||||
|
#include <cmsis_iar.h>
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
|
||||||
|
/* TI CCS specific functions */
|
||||||
|
#include <cmsis_ccs.h>
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
|
||||||
|
/* TASKING carm specific functions */
|
||||||
|
/*
|
||||||
|
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||||
|
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||||
|
* Including the CMSIS ones.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ ) /*------------------ COSMIC Compiler -------------------*/
|
||||||
|
/* Cosmic specific functions */
|
||||||
|
#include <cmsis_csm.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_RegAccFunctions */
|
||||||
|
|
||||||
|
#endif /* __CORE_CMFUNC_H */
|
||||||
880
F1-nolib/inc/cm/core_cmInstr.h
Normal file
880
F1-nolib/inc/cm/core_cmInstr.h
Normal file
@ -0,0 +1,880 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_cmInstr.h
|
||||||
|
* @brief CMSIS Cortex-M Core Instruction Access Header File
|
||||||
|
* @version V4.00
|
||||||
|
* @date 28. August 2014
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2014 ARM LIMITED
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
- Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __CORE_CMINSTR_H
|
||||||
|
#define __CORE_CMINSTR_H
|
||||||
|
|
||||||
|
|
||||||
|
/* ########################## Core Instruction Access ######################### */
|
||||||
|
/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
|
||||||
|
Access to dedicated instructions
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
|
||||||
|
/* ARM armcc specific functions */
|
||||||
|
|
||||||
|
#if (__ARMCC_VERSION < 400677)
|
||||||
|
#error "Please use ARM Compiler Toolchain V4.0.677 or later!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief No Operation
|
||||||
|
|
||||||
|
No Operation does nothing. This instruction can be used for code alignment purposes.
|
||||||
|
*/
|
||||||
|
#define __NOP __nop
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Wait For Interrupt
|
||||||
|
|
||||||
|
Wait For Interrupt is a hint instruction that suspends execution
|
||||||
|
until one of a number of events occurs.
|
||||||
|
*/
|
||||||
|
#define __WFI __wfi
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Wait For Event
|
||||||
|
|
||||||
|
Wait For Event is a hint instruction that permits the processor to enter
|
||||||
|
a low-power state until one of a number of events occurs.
|
||||||
|
*/
|
||||||
|
#define __WFE __wfe
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Send Event
|
||||||
|
|
||||||
|
Send Event is a hint instruction. It causes an event to be signaled to the CPU.
|
||||||
|
*/
|
||||||
|
#define __SEV __sev
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Instruction Synchronization Barrier
|
||||||
|
|
||||||
|
Instruction Synchronization Barrier flushes the pipeline in the processor,
|
||||||
|
so that all instructions following the ISB are fetched from cache or
|
||||||
|
memory, after the instruction has been completed.
|
||||||
|
*/
|
||||||
|
#define __ISB() __isb(0xF)
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Data Synchronization Barrier
|
||||||
|
|
||||||
|
This function acts as a special kind of Data Memory Barrier.
|
||||||
|
It completes when all explicit memory accesses before this instruction complete.
|
||||||
|
*/
|
||||||
|
#define __DSB() __dsb(0xF)
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Data Memory Barrier
|
||||||
|
|
||||||
|
This function ensures the apparent order of the explicit memory operations before
|
||||||
|
and after the instruction, without ensuring their completion.
|
||||||
|
*/
|
||||||
|
#define __DMB() __dmb(0xF)
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Reverse byte order (32 bit)
|
||||||
|
|
||||||
|
This function reverses the byte order in integer value.
|
||||||
|
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
#define __REV __rev
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Reverse byte order (16 bit)
|
||||||
|
|
||||||
|
This function reverses the byte order in two unsigned short values.
|
||||||
|
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
#ifndef __NO_EMBEDDED_ASM
|
||||||
|
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
|
||||||
|
{
|
||||||
|
rev16 r0, r0
|
||||||
|
bx lr
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** \brief Reverse byte order in signed short value
|
||||||
|
|
||||||
|
This function reverses the byte order in a signed short value with sign extension to integer.
|
||||||
|
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
#ifndef __NO_EMBEDDED_ASM
|
||||||
|
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value)
|
||||||
|
{
|
||||||
|
revsh r0, r0
|
||||||
|
bx lr
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Rotate Right in unsigned value (32 bit)
|
||||||
|
|
||||||
|
This function Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
|
||||||
|
|
||||||
|
\param [in] value Value to rotate
|
||||||
|
\param [in] value Number of Bits to rotate
|
||||||
|
\return Rotated value
|
||||||
|
*/
|
||||||
|
#define __ROR __ror
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Breakpoint
|
||||||
|
|
||||||
|
This function causes the processor to enter Debug state.
|
||||||
|
Debug tools can use this to investigate system state when the instruction at a particular address is reached.
|
||||||
|
|
||||||
|
\param [in] value is ignored by the processor.
|
||||||
|
If required, a debugger can use it to store additional information about the breakpoint.
|
||||||
|
*/
|
||||||
|
#define __BKPT(value) __breakpoint(value)
|
||||||
|
|
||||||
|
|
||||||
|
#if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300)
|
||||||
|
|
||||||
|
/** \brief Reverse bit order of value
|
||||||
|
|
||||||
|
This function reverses the bit order of the given value.
|
||||||
|
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
#define __RBIT __rbit
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDR Exclusive (8 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive LDR instruction for 8 bit value.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint8_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDR Exclusive (16 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive LDR instruction for 16 bit values.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint16_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDR Exclusive (32 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive LDR instruction for 32 bit values.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint32_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STR Exclusive (8 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive STR instruction for 8 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
\return 0 Function succeeded
|
||||||
|
\return 1 Function failed
|
||||||
|
*/
|
||||||
|
#define __STREXB(value, ptr) __strex(value, ptr)
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STR Exclusive (16 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive STR instruction for 16 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
\return 0 Function succeeded
|
||||||
|
\return 1 Function failed
|
||||||
|
*/
|
||||||
|
#define __STREXH(value, ptr) __strex(value, ptr)
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STR Exclusive (32 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive STR instruction for 32 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
\return 0 Function succeeded
|
||||||
|
\return 1 Function failed
|
||||||
|
*/
|
||||||
|
#define __STREXW(value, ptr) __strex(value, ptr)
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Remove the exclusive lock
|
||||||
|
|
||||||
|
This function removes the exclusive lock which is created by LDREX.
|
||||||
|
|
||||||
|
*/
|
||||||
|
#define __CLREX __clrex
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Signed Saturate
|
||||||
|
|
||||||
|
This function saturates a signed value.
|
||||||
|
|
||||||
|
\param [in] value Value to be saturated
|
||||||
|
\param [in] sat Bit position to saturate to (1..32)
|
||||||
|
\return Saturated value
|
||||||
|
*/
|
||||||
|
#define __SSAT __ssat
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Unsigned Saturate
|
||||||
|
|
||||||
|
This function saturates an unsigned value.
|
||||||
|
|
||||||
|
\param [in] value Value to be saturated
|
||||||
|
\param [in] sat Bit position to saturate to (0..31)
|
||||||
|
\return Saturated value
|
||||||
|
*/
|
||||||
|
#define __USAT __usat
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Count leading zeros
|
||||||
|
|
||||||
|
This function counts the number of leading zeros of a data value.
|
||||||
|
|
||||||
|
\param [in] value Value to count the leading zeros
|
||||||
|
\return number of leading zeros in value
|
||||||
|
*/
|
||||||
|
#define __CLZ __clz
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Rotate Right with Extend (32 bit)
|
||||||
|
|
||||||
|
This function moves each bit of a bitstring right by one bit. The carry input is shifted in at the left end of the bitstring.
|
||||||
|
|
||||||
|
\param [in] value Value to rotate
|
||||||
|
\return Rotated value
|
||||||
|
*/
|
||||||
|
#ifndef __NO_EMBEDDED_ASM
|
||||||
|
__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
|
||||||
|
{
|
||||||
|
rrx r0, r0
|
||||||
|
bx lr
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDRT Unprivileged (8 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged LDRT instruction for 8 bit value.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint8_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDRT Unprivileged (16 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged LDRT instruction for 16 bit values.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint16_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDRT Unprivileged (32 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged LDRT instruction for 32 bit values.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint32_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STRT Unprivileged (8 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged STRT instruction for 8 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
*/
|
||||||
|
#define __STRBT(value, ptr) __strt(value, ptr)
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STRT Unprivileged (16 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged STRT instruction for 16 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
*/
|
||||||
|
#define __STRHT(value, ptr) __strt(value, ptr)
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STRT Unprivileged (32 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged STRT instruction for 32 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
*/
|
||||||
|
#define __STRT(value, ptr) __strt(value, ptr)
|
||||||
|
|
||||||
|
#endif /* (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300) */
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
|
||||||
|
/* GNU gcc specific functions */
|
||||||
|
|
||||||
|
/* Define macros for porting to both thumb1 and thumb2.
|
||||||
|
* For thumb1, use low register (r0-r7), specified by constrant "l"
|
||||||
|
* Otherwise, use general registers, specified by constrant "r" */
|
||||||
|
#if defined (__thumb__) && !defined (__thumb2__)
|
||||||
|
#define __CMSIS_GCC_OUT_REG(r) "=l" (r)
|
||||||
|
#define __CMSIS_GCC_USE_REG(r) "l" (r)
|
||||||
|
#else
|
||||||
|
#define __CMSIS_GCC_OUT_REG(r) "=r" (r)
|
||||||
|
#define __CMSIS_GCC_USE_REG(r) "r" (r)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** \brief No Operation
|
||||||
|
|
||||||
|
No Operation does nothing. This instruction can be used for code alignment purposes.
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __NOP(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("nop");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Wait For Interrupt
|
||||||
|
|
||||||
|
Wait For Interrupt is a hint instruction that suspends execution
|
||||||
|
until one of a number of events occurs.
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __WFI(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("wfi");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Wait For Event
|
||||||
|
|
||||||
|
Wait For Event is a hint instruction that permits the processor to enter
|
||||||
|
a low-power state until one of a number of events occurs.
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __WFE(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("wfe");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Send Event
|
||||||
|
|
||||||
|
Send Event is a hint instruction. It causes an event to be signaled to the CPU.
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __SEV(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("sev");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Instruction Synchronization Barrier
|
||||||
|
|
||||||
|
Instruction Synchronization Barrier flushes the pipeline in the processor,
|
||||||
|
so that all instructions following the ISB are fetched from cache or
|
||||||
|
memory, after the instruction has been completed.
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __ISB(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("isb");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Data Synchronization Barrier
|
||||||
|
|
||||||
|
This function acts as a special kind of Data Memory Barrier.
|
||||||
|
It completes when all explicit memory accesses before this instruction complete.
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __DSB(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("dsb");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Data Memory Barrier
|
||||||
|
|
||||||
|
This function ensures the apparent order of the explicit memory operations before
|
||||||
|
and after the instruction, without ensuring their completion.
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __DMB(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("dmb");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Reverse byte order (32 bit)
|
||||||
|
|
||||||
|
This function reverses the byte order in integer value.
|
||||||
|
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV(uint32_t value)
|
||||||
|
{
|
||||||
|
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
|
||||||
|
return __builtin_bswap32(value);
|
||||||
|
#else
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
|
||||||
|
return(result);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Reverse byte order (16 bit)
|
||||||
|
|
||||||
|
This function reverses the byte order in two unsigned short values.
|
||||||
|
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV16(uint32_t value)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Reverse byte order in signed short value
|
||||||
|
|
||||||
|
This function reverses the byte order in a signed short value with sign extension to integer.
|
||||||
|
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __REVSH(int32_t value)
|
||||||
|
{
|
||||||
|
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||||
|
return (short)__builtin_bswap16(value);
|
||||||
|
#else
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
|
||||||
|
return(result);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Rotate Right in unsigned value (32 bit)
|
||||||
|
|
||||||
|
This function Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
|
||||||
|
|
||||||
|
\param [in] value Value to rotate
|
||||||
|
\param [in] value Number of Bits to rotate
|
||||||
|
\return Rotated value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
return (op1 >> op2) | (op1 << (32 - op2));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Breakpoint
|
||||||
|
|
||||||
|
This function causes the processor to enter Debug state.
|
||||||
|
Debug tools can use this to investigate system state when the instruction at a particular address is reached.
|
||||||
|
|
||||||
|
\param [in] value is ignored by the processor.
|
||||||
|
If required, a debugger can use it to store additional information about the breakpoint.
|
||||||
|
*/
|
||||||
|
#define __BKPT(value) __ASM volatile ("bkpt "#value)
|
||||||
|
|
||||||
|
|
||||||
|
#if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300)
|
||||||
|
|
||||||
|
/** \brief Reverse bit order of value
|
||||||
|
|
||||||
|
This function reverses the bit order of the given value.
|
||||||
|
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDR Exclusive (8 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive LDR instruction for 8 bit value.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint8_t at (*ptr)
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||||
|
__ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
|
||||||
|
#else
|
||||||
|
/* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
|
||||||
|
accepted by assembler. So has to use following less efficient pattern.
|
||||||
|
*/
|
||||||
|
__ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
|
||||||
|
#endif
|
||||||
|
return ((uint8_t) result); /* Add explicit type cast here */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDR Exclusive (16 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive LDR instruction for 16 bit values.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint16_t at (*ptr)
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||||
|
__ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
|
||||||
|
#else
|
||||||
|
/* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
|
||||||
|
accepted by assembler. So has to use following less efficient pattern.
|
||||||
|
*/
|
||||||
|
__ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
|
||||||
|
#endif
|
||||||
|
return ((uint16_t) result); /* Add explicit type cast here */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDR Exclusive (32 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive LDR instruction for 32 bit values.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint32_t at (*ptr)
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STR Exclusive (8 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive STR instruction for 8 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
\return 0 Function succeeded
|
||||||
|
\return 1 Function failed
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STR Exclusive (16 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive STR instruction for 16 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
\return 0 Function succeeded
|
||||||
|
\return 1 Function failed
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STR Exclusive (32 bit)
|
||||||
|
|
||||||
|
This function executes a exclusive STR instruction for 32 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
\return 0 Function succeeded
|
||||||
|
\return 1 Function failed
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Remove the exclusive lock
|
||||||
|
|
||||||
|
This function removes the exclusive lock which is created by LDREX.
|
||||||
|
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __CLREX(void)
|
||||||
|
{
|
||||||
|
__ASM volatile ("clrex" ::: "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Signed Saturate
|
||||||
|
|
||||||
|
This function saturates a signed value.
|
||||||
|
|
||||||
|
\param [in] value Value to be saturated
|
||||||
|
\param [in] sat Bit position to saturate to (1..32)
|
||||||
|
\return Saturated value
|
||||||
|
*/
|
||||||
|
#define __SSAT(ARG1,ARG2) \
|
||||||
|
({ \
|
||||||
|
uint32_t __RES, __ARG1 = (ARG1); \
|
||||||
|
__ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
|
||||||
|
__RES; \
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Unsigned Saturate
|
||||||
|
|
||||||
|
This function saturates an unsigned value.
|
||||||
|
|
||||||
|
\param [in] value Value to be saturated
|
||||||
|
\param [in] sat Bit position to saturate to (0..31)
|
||||||
|
\return Saturated value
|
||||||
|
*/
|
||||||
|
#define __USAT(ARG1,ARG2) \
|
||||||
|
({ \
|
||||||
|
uint32_t __RES, __ARG1 = (ARG1); \
|
||||||
|
__ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
|
||||||
|
__RES; \
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Count leading zeros
|
||||||
|
|
||||||
|
This function counts the number of leading zeros of a data value.
|
||||||
|
|
||||||
|
\param [in] value Value to count the leading zeros
|
||||||
|
\return number of leading zeros in value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __CLZ(uint32_t value)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("clz %0, %1" : "=r" (result) : "r" (value) );
|
||||||
|
return ((uint8_t) result); /* Add explicit type cast here */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Rotate Right with Extend (32 bit)
|
||||||
|
|
||||||
|
This function moves each bit of a bitstring right by one bit. The carry input is shifted in at the left end of the bitstring.
|
||||||
|
|
||||||
|
\param [in] value Value to rotate
|
||||||
|
\return Rotated value
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RRX(uint32_t value)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDRT Unprivileged (8 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged LDRT instruction for 8 bit value.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint8_t at (*ptr)
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *addr)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||||
|
__ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*addr) );
|
||||||
|
#else
|
||||||
|
/* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
|
||||||
|
accepted by assembler. So has to use following less efficient pattern.
|
||||||
|
*/
|
||||||
|
__ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
|
||||||
|
#endif
|
||||||
|
return ((uint8_t) result); /* Add explicit type cast here */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDRT Unprivileged (16 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged LDRT instruction for 16 bit values.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint16_t at (*ptr)
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *addr)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||||
|
__ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*addr) );
|
||||||
|
#else
|
||||||
|
/* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
|
||||||
|
accepted by assembler. So has to use following less efficient pattern.
|
||||||
|
*/
|
||||||
|
__ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
|
||||||
|
#endif
|
||||||
|
return ((uint16_t) result); /* Add explicit type cast here */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief LDRT Unprivileged (32 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged LDRT instruction for 32 bit values.
|
||||||
|
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint32_t at (*ptr)
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *addr)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*addr) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STRT Unprivileged (8 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged STRT instruction for 8 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *addr)
|
||||||
|
{
|
||||||
|
__ASM volatile ("strbt %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STRT Unprivileged (16 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged STRT instruction for 16 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *addr)
|
||||||
|
{
|
||||||
|
__ASM volatile ("strht %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief STRT Unprivileged (32 bit)
|
||||||
|
|
||||||
|
This function executes a Unprivileged STRT instruction for 32 bit values.
|
||||||
|
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
*/
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *addr)
|
||||||
|
{
|
||||||
|
__ASM volatile ("strt %1, %0" : "=Q" (*addr) : "r" (value) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300) */
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
|
||||||
|
/* IAR iccarm specific functions */
|
||||||
|
#include <cmsis_iar.h>
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
|
||||||
|
/* TI CCS specific functions */
|
||||||
|
#include <cmsis_ccs.h>
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
|
||||||
|
/* TASKING carm specific functions */
|
||||||
|
/*
|
||||||
|
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||||
|
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||||
|
* Including the CMSIS ones.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ ) /*------------------ COSMIC Compiler -------------------*/
|
||||||
|
/* Cosmic specific functions */
|
||||||
|
#include <cmsis_csm.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
|
||||||
|
|
||||||
|
#endif /* __CORE_CMINSTR_H */
|
||||||
697
F1-nolib/inc/cm/core_cmSimd.h
Normal file
697
F1-nolib/inc/cm/core_cmSimd.h
Normal file
@ -0,0 +1,697 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_cmSimd.h
|
||||||
|
* @brief CMSIS Cortex-M SIMD Header File
|
||||||
|
* @version V4.00
|
||||||
|
* @date 22. August 2014
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2014 ARM LIMITED
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
- Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CORE_CMSIMD_H
|
||||||
|
#define __CORE_CMSIMD_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Hardware Abstraction Layer
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/* ################### Compiler specific Intrinsics ########################### */
|
||||||
|
/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
|
||||||
|
Access to dedicated SIMD instructions
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
|
||||||
|
/* ARM armcc specific functions */
|
||||||
|
#define __SADD8 __sadd8
|
||||||
|
#define __QADD8 __qadd8
|
||||||
|
#define __SHADD8 __shadd8
|
||||||
|
#define __UADD8 __uadd8
|
||||||
|
#define __UQADD8 __uqadd8
|
||||||
|
#define __UHADD8 __uhadd8
|
||||||
|
#define __SSUB8 __ssub8
|
||||||
|
#define __QSUB8 __qsub8
|
||||||
|
#define __SHSUB8 __shsub8
|
||||||
|
#define __USUB8 __usub8
|
||||||
|
#define __UQSUB8 __uqsub8
|
||||||
|
#define __UHSUB8 __uhsub8
|
||||||
|
#define __SADD16 __sadd16
|
||||||
|
#define __QADD16 __qadd16
|
||||||
|
#define __SHADD16 __shadd16
|
||||||
|
#define __UADD16 __uadd16
|
||||||
|
#define __UQADD16 __uqadd16
|
||||||
|
#define __UHADD16 __uhadd16
|
||||||
|
#define __SSUB16 __ssub16
|
||||||
|
#define __QSUB16 __qsub16
|
||||||
|
#define __SHSUB16 __shsub16
|
||||||
|
#define __USUB16 __usub16
|
||||||
|
#define __UQSUB16 __uqsub16
|
||||||
|
#define __UHSUB16 __uhsub16
|
||||||
|
#define __SASX __sasx
|
||||||
|
#define __QASX __qasx
|
||||||
|
#define __SHASX __shasx
|
||||||
|
#define __UASX __uasx
|
||||||
|
#define __UQASX __uqasx
|
||||||
|
#define __UHASX __uhasx
|
||||||
|
#define __SSAX __ssax
|
||||||
|
#define __QSAX __qsax
|
||||||
|
#define __SHSAX __shsax
|
||||||
|
#define __USAX __usax
|
||||||
|
#define __UQSAX __uqsax
|
||||||
|
#define __UHSAX __uhsax
|
||||||
|
#define __USAD8 __usad8
|
||||||
|
#define __USADA8 __usada8
|
||||||
|
#define __SSAT16 __ssat16
|
||||||
|
#define __USAT16 __usat16
|
||||||
|
#define __UXTB16 __uxtb16
|
||||||
|
#define __UXTAB16 __uxtab16
|
||||||
|
#define __SXTB16 __sxtb16
|
||||||
|
#define __SXTAB16 __sxtab16
|
||||||
|
#define __SMUAD __smuad
|
||||||
|
#define __SMUADX __smuadx
|
||||||
|
#define __SMLAD __smlad
|
||||||
|
#define __SMLADX __smladx
|
||||||
|
#define __SMLALD __smlald
|
||||||
|
#define __SMLALDX __smlaldx
|
||||||
|
#define __SMUSD __smusd
|
||||||
|
#define __SMUSDX __smusdx
|
||||||
|
#define __SMLSD __smlsd
|
||||||
|
#define __SMLSDX __smlsdx
|
||||||
|
#define __SMLSLD __smlsld
|
||||||
|
#define __SMLSLDX __smlsldx
|
||||||
|
#define __SEL __sel
|
||||||
|
#define __QADD __qadd
|
||||||
|
#define __QSUB __qsub
|
||||||
|
|
||||||
|
#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
|
||||||
|
((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
|
||||||
|
|
||||||
|
#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
|
||||||
|
((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
|
||||||
|
|
||||||
|
#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
|
||||||
|
((int64_t)(ARG3) << 32) ) >> 32))
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
|
||||||
|
/* GNU gcc specific functions */
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define __SSAT16(ARG1,ARG2) \
|
||||||
|
({ \
|
||||||
|
uint32_t __RES, __ARG1 = (ARG1); \
|
||||||
|
__ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
|
||||||
|
__RES; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define __USAT16(ARG1,ARG2) \
|
||||||
|
({ \
|
||||||
|
uint32_t __RES, __ARG1 = (ARG1); \
|
||||||
|
__ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
|
||||||
|
__RES; \
|
||||||
|
})
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
|
||||||
|
{
|
||||||
|
union llreg_u{
|
||||||
|
uint32_t w32[2];
|
||||||
|
uint64_t w64;
|
||||||
|
} llr;
|
||||||
|
llr.w64 = acc;
|
||||||
|
|
||||||
|
#ifndef __ARMEB__ // Little endian
|
||||||
|
__ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
|
||||||
|
#else // Big endian
|
||||||
|
__ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(llr.w64);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
|
||||||
|
{
|
||||||
|
union llreg_u{
|
||||||
|
uint32_t w32[2];
|
||||||
|
uint64_t w64;
|
||||||
|
} llr;
|
||||||
|
llr.w64 = acc;
|
||||||
|
|
||||||
|
#ifndef __ARMEB__ // Little endian
|
||||||
|
__ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
|
||||||
|
#else // Big endian
|
||||||
|
__ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(llr.w64);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
|
||||||
|
{
|
||||||
|
union llreg_u{
|
||||||
|
uint32_t w32[2];
|
||||||
|
uint64_t w64;
|
||||||
|
} llr;
|
||||||
|
llr.w64 = acc;
|
||||||
|
|
||||||
|
#ifndef __ARMEB__ // Little endian
|
||||||
|
__ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
|
||||||
|
#else // Big endian
|
||||||
|
__ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(llr.w64);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
|
||||||
|
{
|
||||||
|
union llreg_u{
|
||||||
|
uint32_t w32[2];
|
||||||
|
uint64_t w64;
|
||||||
|
} llr;
|
||||||
|
llr.w64 = acc;
|
||||||
|
|
||||||
|
#ifndef __ARMEB__ // Little endian
|
||||||
|
__ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
|
||||||
|
#else // Big endian
|
||||||
|
__ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(llr.w64);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB(uint32_t op1, uint32_t op2)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define __PKHBT(ARG1,ARG2,ARG3) \
|
||||||
|
({ \
|
||||||
|
uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
|
||||||
|
__ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
|
||||||
|
__RES; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define __PKHTB(ARG1,ARG2,ARG3) \
|
||||||
|
({ \
|
||||||
|
uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
|
||||||
|
if (ARG3 == 0) \
|
||||||
|
__ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
|
||||||
|
else \
|
||||||
|
__ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
|
||||||
|
__RES; \
|
||||||
|
})
|
||||||
|
|
||||||
|
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
|
||||||
|
{
|
||||||
|
int32_t result;
|
||||||
|
|
||||||
|
__ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
|
||||||
|
/* IAR iccarm specific functions */
|
||||||
|
#include <cmsis_iar.h>
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
|
||||||
|
/* TI CCS specific functions */
|
||||||
|
#include <cmsis_ccs.h>
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
|
||||||
|
/* TASKING carm specific functions */
|
||||||
|
/* not yet supported */
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ ) /*------------------ COSMIC Compiler -------------------*/
|
||||||
|
/* Cosmic specific functions */
|
||||||
|
#include <cmsis_csm.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SIMD_intrinsics */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_CMSIMD_H */
|
||||||
842
F1-nolib/inc/cm/core_sc000.h
Normal file
842
F1-nolib/inc/cm/core_sc000.h
Normal file
@ -0,0 +1,842 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_sc000.h
|
||||||
|
* @brief CMSIS SC000 Core Peripheral Access Layer Header File
|
||||||
|
* @version V4.00
|
||||||
|
* @date 22. August 2014
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2014 ARM LIMITED
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
- Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CORE_SC000_H_GENERIC
|
||||||
|
#define __CORE_SC000_H_GENERIC
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
|
||||||
|
CMSIS violates the following MISRA-C:2004 rules:
|
||||||
|
|
||||||
|
\li Required Rule 8.5, object/function definition in header file.<br>
|
||||||
|
Function definitions in header files are used to allow 'inlining'.
|
||||||
|
|
||||||
|
\li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
|
||||||
|
Unions are used for effective representation of core registers.
|
||||||
|
|
||||||
|
\li Advisory Rule 19.7, Function-like macro defined.<br>
|
||||||
|
Function-like macros are used to allow more efficient code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* CMSIS definitions
|
||||||
|
******************************************************************************/
|
||||||
|
/** \ingroup SC000
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* CMSIS SC000 definitions */
|
||||||
|
#define __SC000_CMSIS_VERSION_MAIN (0x04) /*!< [31:16] CMSIS HAL main version */
|
||||||
|
#define __SC000_CMSIS_VERSION_SUB (0x00) /*!< [15:0] CMSIS HAL sub version */
|
||||||
|
#define __SC000_CMSIS_VERSION ((__SC000_CMSIS_VERSION_MAIN << 16) | \
|
||||||
|
__SC000_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
|
||||||
|
|
||||||
|
#define __CORTEX_SC (000) /*!< Cortex secure core */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#define __ASM __asm /*!< asm keyword for ARM Compiler */
|
||||||
|
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
|
||||||
|
#define __STATIC_INLINE static __inline
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for GNU Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for GNU Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for IAR Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TI CCS Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for TASKING Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#define __packed
|
||||||
|
#define __ASM _asm /*!< asm keyword for COSMIC Compiler */
|
||||||
|
#define __INLINE inline /*use -pc99 on compile line !< inline keyword for COSMIC Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** __FPU_USED indicates whether an FPU is used or not.
|
||||||
|
This core does not support an FPU at all
|
||||||
|
*/
|
||||||
|
#define __FPU_USED 0
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#if defined __TARGET_FPU_VFP
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#if defined __ARMVFP__
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#if defined __TI__VFP_SUPPORT____
|
||||||
|
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#if defined __FPU_VFP__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ ) /* Cosmic */
|
||||||
|
#if ( __CSMC__ & 0x400) // FPU present for parser
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h> /* standard types definitions */
|
||||||
|
#include <core_cmInstr.h> /* Core Instruction Access */
|
||||||
|
#include <core_cmFunc.h> /* Core Function Access */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_SC000_H_GENERIC */
|
||||||
|
|
||||||
|
#ifndef __CMSIS_GENERIC
|
||||||
|
|
||||||
|
#ifndef __CORE_SC000_H_DEPENDANT
|
||||||
|
#define __CORE_SC000_H_DEPENDANT
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* check device defines and use defaults */
|
||||||
|
#if defined __CHECK_DEVICE_DEFINES
|
||||||
|
#ifndef __SC000_REV
|
||||||
|
#define __SC000_REV 0x0000
|
||||||
|
#warning "__SC000_REV not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __MPU_PRESENT
|
||||||
|
#define __MPU_PRESENT 0
|
||||||
|
#warning "__MPU_PRESENT not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __NVIC_PRIO_BITS
|
||||||
|
#define __NVIC_PRIO_BITS 2
|
||||||
|
#warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __Vendor_SysTickConfig
|
||||||
|
#define __Vendor_SysTickConfig 0
|
||||||
|
#warning "__Vendor_SysTickConfig not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* IO definitions (access restrictions to peripheral registers) */
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_glob_defs CMSIS Global Defines
|
||||||
|
|
||||||
|
<strong>IO Type Qualifiers</strong> are used
|
||||||
|
\li to specify the access to peripheral variables.
|
||||||
|
\li for automatic generation of peripheral register debug information.
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define __I volatile /*!< Defines 'read only' permissions */
|
||||||
|
#else
|
||||||
|
#define __I volatile const /*!< Defines 'read only' permissions */
|
||||||
|
#endif
|
||||||
|
#define __O volatile /*!< Defines 'write only' permissions */
|
||||||
|
#define __IO volatile /*!< Defines 'read / write' permissions */
|
||||||
|
|
||||||
|
/*@} end of group SC000 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Register Abstraction
|
||||||
|
Core Register contain:
|
||||||
|
- Core Register
|
||||||
|
- Core NVIC Register
|
||||||
|
- Core SCB Register
|
||||||
|
- Core SysTick Register
|
||||||
|
- Core MPU Register
|
||||||
|
******************************************************************************/
|
||||||
|
/** \defgroup CMSIS_core_register Defines and Type Definitions
|
||||||
|
\brief Type definitions and defines for Cortex-M processor based devices.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CORE Status and Control Registers
|
||||||
|
\brief Core Register type definitions.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Union type to access the Application Program Status Register (APSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
#if (__CORTEX_M != 0x04)
|
||||||
|
uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */
|
||||||
|
#else
|
||||||
|
uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */
|
||||||
|
uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
|
||||||
|
uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */
|
||||||
|
#endif
|
||||||
|
uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} APSR_Type;
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Union type to access the Interrupt Program Status Register (IPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} IPSR_Type;
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Union type to access the Special-Purpose Program Status Registers (xPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
#if (__CORTEX_M != 0x04)
|
||||||
|
uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
|
||||||
|
#else
|
||||||
|
uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */
|
||||||
|
uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
|
||||||
|
uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */
|
||||||
|
#endif
|
||||||
|
uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
|
||||||
|
uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */
|
||||||
|
uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} xPSR_Type;
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Union type to access the Control Registers (CONTROL).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */
|
||||||
|
uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
|
||||||
|
uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */
|
||||||
|
uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} CONTROL_Type;
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_CORE */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
|
||||||
|
\brief Type definitions for the NVIC Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IO uint32_t ISER[1]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
|
||||||
|
uint32_t RESERVED0[31];
|
||||||
|
__IO uint32_t ICER[1]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
|
||||||
|
uint32_t RSERVED1[31];
|
||||||
|
__IO uint32_t ISPR[1]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
|
||||||
|
uint32_t RESERVED2[31];
|
||||||
|
__IO uint32_t ICPR[1]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
|
||||||
|
uint32_t RESERVED3[31];
|
||||||
|
uint32_t RESERVED4[64];
|
||||||
|
__IO uint32_t IP[8]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
|
||||||
|
} NVIC_Type;
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_NVIC */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SCB System Control Block (SCB)
|
||||||
|
\brief Type definitions for the System Control Block Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the System Control Block (SCB).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__I uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
|
||||||
|
__IO uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
|
||||||
|
__IO uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */
|
||||||
|
__IO uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
|
||||||
|
__IO uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
|
||||||
|
__IO uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
|
||||||
|
uint32_t RESERVED0[1];
|
||||||
|
__IO uint32_t SHP[2]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
|
||||||
|
__IO uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
|
||||||
|
uint32_t RESERVED1[154];
|
||||||
|
__IO uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Register */
|
||||||
|
} SCB_Type;
|
||||||
|
|
||||||
|
/* SCB CPUID Register Definitions */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Pos 24 /*!< SCB CPUID: IMPLEMENTER Position */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_VARIANT_Pos 20 /*!< SCB CPUID: VARIANT Position */
|
||||||
|
#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Pos 16 /*!< SCB CPUID: ARCHITECTURE Position */
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_PARTNO_Pos 4 /*!< SCB CPUID: PARTNO Position */
|
||||||
|
#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_REVISION_Pos 0 /*!< SCB CPUID: REVISION Position */
|
||||||
|
#define SCB_CPUID_REVISION_Msk (0xFUL << SCB_CPUID_REVISION_Pos) /*!< SCB CPUID: REVISION Mask */
|
||||||
|
|
||||||
|
/* SCB Interrupt Control State Register Definitions */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Pos 31 /*!< SCB ICSR: NMIPENDSET Position */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVSET_Pos 28 /*!< SCB ICSR: PENDSVSET Position */
|
||||||
|
#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Pos 27 /*!< SCB ICSR: PENDSVCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTSET_Pos 26 /*!< SCB ICSR: PENDSTSET Position */
|
||||||
|
#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Pos 25 /*!< SCB ICSR: PENDSTCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Pos 23 /*!< SCB ICSR: ISRPREEMPT Position */
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPENDING_Pos 22 /*!< SCB ICSR: ISRPENDING Position */
|
||||||
|
#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTPENDING_Pos 12 /*!< SCB ICSR: VECTPENDING Position */
|
||||||
|
#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Pos 0 /*!< SCB ICSR: VECTACTIVE Position */
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos) /*!< SCB ICSR: VECTACTIVE Mask */
|
||||||
|
|
||||||
|
/* SCB Interrupt Control State Register Definitions */
|
||||||
|
#define SCB_VTOR_TBLOFF_Pos 7 /*!< SCB VTOR: TBLOFF Position */
|
||||||
|
#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
|
||||||
|
|
||||||
|
/* SCB Application Interrupt and Reset Control Register Definitions */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Pos 16 /*!< SCB AIRCR: VECTKEY Position */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Pos 16 /*!< SCB AIRCR: VECTKEYSTAT Position */
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Pos 15 /*!< SCB AIRCR: ENDIANESS Position */
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Pos 2 /*!< SCB AIRCR: SYSRESETREQ Position */
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Pos 1 /*!< SCB AIRCR: VECTCLRACTIVE Position */
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
|
||||||
|
|
||||||
|
/* SCB System Control Register Definitions */
|
||||||
|
#define SCB_SCR_SEVONPEND_Pos 4 /*!< SCB SCR: SEVONPEND Position */
|
||||||
|
#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Pos 2 /*!< SCB SCR: SLEEPDEEP Position */
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Pos 1 /*!< SCB SCR: SLEEPONEXIT Position */
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
|
||||||
|
|
||||||
|
/* SCB Configuration Control Register Definitions */
|
||||||
|
#define SCB_CCR_STKALIGN_Pos 9 /*!< SCB CCR: STKALIGN Position */
|
||||||
|
#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
|
||||||
|
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Pos 3 /*!< SCB CCR: UNALIGN_TRP Position */
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
|
||||||
|
|
||||||
|
/* SCB System Handler Control and State Register Definitions */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Pos 15 /*!< SCB SHCSR: SVCALLPENDED Position */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
|
||||||
|
|
||||||
|
/* SCB Security Features Register Definitions */
|
||||||
|
#define SCB_SFCR_UNIBRTIMING_Pos 0 /*!< SCB SFCR: UNIBRTIMING Position */
|
||||||
|
#define SCB_SFCR_UNIBRTIMING_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SFCR: UNIBRTIMING Mask */
|
||||||
|
|
||||||
|
#define SCB_SFCR_SECKEY_Pos 16 /*!< SCB SFCR: SECKEY Position */
|
||||||
|
#define SCB_SFCR_SECKEY_Msk (0xFFFFUL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SFCR: SECKEY Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SCB */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB)
|
||||||
|
\brief Type definitions for the System Control and ID Register not in the SCB
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the System Control and ID Register not in the SCB.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t RESERVED0[2];
|
||||||
|
__IO uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */
|
||||||
|
} SCnSCB_Type;
|
||||||
|
|
||||||
|
/* Auxiliary Control Register Definitions */
|
||||||
|
#define SCnSCB_ACTLR_DISMCYCINT_Pos 0 /*!< ACTLR: DISMCYCINT Position */
|
||||||
|
#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL << SCnSCB_ACTLR_DISMCYCINT_Pos) /*!< ACTLR: DISMCYCINT Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SCnotSCB */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SysTick System Tick Timer (SysTick)
|
||||||
|
\brief Type definitions for the System Timer Registers.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the System Timer (SysTick).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IO uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
|
||||||
|
__IO uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
|
||||||
|
__IO uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
|
||||||
|
__I uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
|
||||||
|
} SysTick_Type;
|
||||||
|
|
||||||
|
/* SysTick Control / Status Register Definitions */
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Pos 16 /*!< SysTick CTRL: COUNTFLAG Position */
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Pos 2 /*!< SysTick CTRL: CLKSOURCE Position */
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_TICKINT_Pos 1 /*!< SysTick CTRL: TICKINT Position */
|
||||||
|
#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_ENABLE_Pos 0 /*!< SysTick CTRL: ENABLE Position */
|
||||||
|
#define SysTick_CTRL_ENABLE_Msk (1UL << SysTick_CTRL_ENABLE_Pos) /*!< SysTick CTRL: ENABLE Mask */
|
||||||
|
|
||||||
|
/* SysTick Reload Register Definitions */
|
||||||
|
#define SysTick_LOAD_RELOAD_Pos 0 /*!< SysTick LOAD: RELOAD Position */
|
||||||
|
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos) /*!< SysTick LOAD: RELOAD Mask */
|
||||||
|
|
||||||
|
/* SysTick Current Register Definitions */
|
||||||
|
#define SysTick_VAL_CURRENT_Pos 0 /*!< SysTick VAL: CURRENT Position */
|
||||||
|
#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) /*!< SysTick VAL: CURRENT Mask */
|
||||||
|
|
||||||
|
/* SysTick Calibration Register Definitions */
|
||||||
|
#define SysTick_CALIB_NOREF_Pos 31 /*!< SysTick CALIB: NOREF Position */
|
||||||
|
#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_SKEW_Pos 30 /*!< SysTick CALIB: SKEW Position */
|
||||||
|
#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_TENMS_Pos 0 /*!< SysTick CALIB: TENMS Position */
|
||||||
|
#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL << SysTick_CALIB_TENMS_Pos) /*!< SysTick CALIB: TENMS Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SysTick */
|
||||||
|
|
||||||
|
#if (__MPU_PRESENT == 1)
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_MPU Memory Protection Unit (MPU)
|
||||||
|
\brief Type definitions for the Memory Protection Unit (MPU)
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Structure type to access the Memory Protection Unit (MPU).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__I uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */
|
||||||
|
__IO uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */
|
||||||
|
__IO uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */
|
||||||
|
__IO uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */
|
||||||
|
__IO uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */
|
||||||
|
} MPU_Type;
|
||||||
|
|
||||||
|
/* MPU Type Register */
|
||||||
|
#define MPU_TYPE_IREGION_Pos 16 /*!< MPU TYPE: IREGION Position */
|
||||||
|
#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */
|
||||||
|
|
||||||
|
#define MPU_TYPE_DREGION_Pos 8 /*!< MPU TYPE: DREGION Position */
|
||||||
|
#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */
|
||||||
|
|
||||||
|
#define MPU_TYPE_SEPARATE_Pos 0 /*!< MPU TYPE: SEPARATE Position */
|
||||||
|
#define MPU_TYPE_SEPARATE_Msk (1UL << MPU_TYPE_SEPARATE_Pos) /*!< MPU TYPE: SEPARATE Mask */
|
||||||
|
|
||||||
|
/* MPU Control Register */
|
||||||
|
#define MPU_CTRL_PRIVDEFENA_Pos 2 /*!< MPU CTRL: PRIVDEFENA Position */
|
||||||
|
#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */
|
||||||
|
|
||||||
|
#define MPU_CTRL_HFNMIENA_Pos 1 /*!< MPU CTRL: HFNMIENA Position */
|
||||||
|
#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */
|
||||||
|
|
||||||
|
#define MPU_CTRL_ENABLE_Pos 0 /*!< MPU CTRL: ENABLE Position */
|
||||||
|
#define MPU_CTRL_ENABLE_Msk (1UL << MPU_CTRL_ENABLE_Pos) /*!< MPU CTRL: ENABLE Mask */
|
||||||
|
|
||||||
|
/* MPU Region Number Register */
|
||||||
|
#define MPU_RNR_REGION_Pos 0 /*!< MPU RNR: REGION Position */
|
||||||
|
#define MPU_RNR_REGION_Msk (0xFFUL << MPU_RNR_REGION_Pos) /*!< MPU RNR: REGION Mask */
|
||||||
|
|
||||||
|
/* MPU Region Base Address Register */
|
||||||
|
#define MPU_RBAR_ADDR_Pos 8 /*!< MPU RBAR: ADDR Position */
|
||||||
|
#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */
|
||||||
|
|
||||||
|
#define MPU_RBAR_VALID_Pos 4 /*!< MPU RBAR: VALID Position */
|
||||||
|
#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */
|
||||||
|
|
||||||
|
#define MPU_RBAR_REGION_Pos 0 /*!< MPU RBAR: REGION Position */
|
||||||
|
#define MPU_RBAR_REGION_Msk (0xFUL << MPU_RBAR_REGION_Pos) /*!< MPU RBAR: REGION Mask */
|
||||||
|
|
||||||
|
/* MPU Region Attribute and Size Register */
|
||||||
|
#define MPU_RASR_ATTRS_Pos 16 /*!< MPU RASR: MPU Region Attribute field Position */
|
||||||
|
#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_XN_Pos 28 /*!< MPU RASR: ATTRS.XN Position */
|
||||||
|
#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_AP_Pos 24 /*!< MPU RASR: ATTRS.AP Position */
|
||||||
|
#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_TEX_Pos 19 /*!< MPU RASR: ATTRS.TEX Position */
|
||||||
|
#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_S_Pos 18 /*!< MPU RASR: ATTRS.S Position */
|
||||||
|
#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_C_Pos 17 /*!< MPU RASR: ATTRS.C Position */
|
||||||
|
#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_B_Pos 16 /*!< MPU RASR: ATTRS.B Position */
|
||||||
|
#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_SRD_Pos 8 /*!< MPU RASR: Sub-Region Disable Position */
|
||||||
|
#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_SIZE_Pos 1 /*!< MPU RASR: Region Size Field Position */
|
||||||
|
#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_ENABLE_Pos 0 /*!< MPU RASR: Region enable bit Position */
|
||||||
|
#define MPU_RASR_ENABLE_Msk (1UL << MPU_RASR_ENABLE_Pos) /*!< MPU RASR: Region enable bit Disable Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_MPU */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
|
||||||
|
\brief SC000 Core Debug Registers (DCB registers, SHCSR, and DFSR)
|
||||||
|
are only accessible over DAP and not via processor. Therefore
|
||||||
|
they are not covered by the Cortex-M0 header file.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
/*@} end of group CMSIS_CoreDebug */
|
||||||
|
|
||||||
|
|
||||||
|
/** \ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_core_base Core Definitions
|
||||||
|
\brief Definitions for base addresses, unions, and structures.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Memory mapping of SC000 Hardware */
|
||||||
|
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
|
||||||
|
#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
|
||||||
|
#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
|
||||||
|
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
|
||||||
|
|
||||||
|
#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */
|
||||||
|
#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
|
||||||
|
#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
|
||||||
|
#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
|
||||||
|
|
||||||
|
#if (__MPU_PRESENT == 1)
|
||||||
|
#define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */
|
||||||
|
#define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Hardware Abstraction Layer
|
||||||
|
Core Function Interface contains:
|
||||||
|
- Core NVIC Functions
|
||||||
|
- Core SysTick Functions
|
||||||
|
- Core Register Access Functions
|
||||||
|
******************************************************************************/
|
||||||
|
/** \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ########################## NVIC functions #################################### */
|
||||||
|
/** \ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_NVICFunctions NVIC Functions
|
||||||
|
\brief Functions that manage interrupts and exceptions via the NVIC.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Interrupt Priorities are WORD accessible only under ARMv6M */
|
||||||
|
/* The following MACROS handle generation of the register offset and byte masks */
|
||||||
|
#define _BIT_SHIFT(IRQn) ( (((uint32_t)(IRQn) ) & 0x03) * 8 )
|
||||||
|
#define _SHP_IDX(IRQn) ( ((((uint32_t)(IRQn) & 0x0F)-8) >> 2) )
|
||||||
|
#define _IP_IDX(IRQn) ( ((uint32_t)(IRQn) >> 2) )
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Enable External Interrupt
|
||||||
|
|
||||||
|
The function enables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Disable External Interrupt
|
||||||
|
|
||||||
|
The function disables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Pending Interrupt
|
||||||
|
|
||||||
|
The function reads the pending register in the NVIC and returns the pending bit
|
||||||
|
for the specified interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
|
||||||
|
\return 0 Interrupt status is not pending.
|
||||||
|
\return 1 Interrupt status is pending.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
return((uint32_t) ((NVIC->ISPR[0] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Pending Interrupt
|
||||||
|
|
||||||
|
The function sets the pending bit of an external interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Clear Pending Interrupt
|
||||||
|
|
||||||
|
The function clears the pending bit of an external interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Set Interrupt Priority
|
||||||
|
|
||||||
|
The function sets the priority of an interrupt.
|
||||||
|
|
||||||
|
\note The priority cannot be set for every core interrupt.
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\param [in] priority Priority to set.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
||||||
|
{
|
||||||
|
if(IRQn < 0) {
|
||||||
|
SCB->SHP[_SHP_IDX(IRQn)] = (SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8 - __NVIC_PRIO_BITS)) & 0xFF) << _BIT_SHIFT(IRQn)); }
|
||||||
|
else {
|
||||||
|
NVIC->IP[_IP_IDX(IRQn)] = (NVIC->IP[_IP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8 - __NVIC_PRIO_BITS)) & 0xFF) << _BIT_SHIFT(IRQn)); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Get Interrupt Priority
|
||||||
|
|
||||||
|
The function reads the priority of an interrupt. The interrupt
|
||||||
|
number can be positive to specify an external (device specific)
|
||||||
|
interrupt, or negative to specify an internal (core) interrupt.
|
||||||
|
|
||||||
|
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\return Interrupt Priority. Value is aligned automatically to the implemented
|
||||||
|
priority bits of the microcontroller.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(IRQn < 0) {
|
||||||
|
return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M0 system interrupts */
|
||||||
|
else {
|
||||||
|
return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief System Reset
|
||||||
|
|
||||||
|
The function initiates a system reset request to reset the MCU.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SystemReset(void)
|
||||||
|
{
|
||||||
|
__DSB(); /* Ensure all outstanding memory accesses included
|
||||||
|
buffered write are completed before reset */
|
||||||
|
SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
|
||||||
|
SCB_AIRCR_SYSRESETREQ_Msk);
|
||||||
|
__DSB(); /* Ensure completion of memory access */
|
||||||
|
while(1); /* wait until reset */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_NVICFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ################################## SysTick function ############################################ */
|
||||||
|
/** \ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_SysTickFunctions SysTick Functions
|
||||||
|
\brief Functions that configure the System.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (__Vendor_SysTickConfig == 0)
|
||||||
|
|
||||||
|
/** \brief System Tick Configuration
|
||||||
|
|
||||||
|
The function initializes the System Timer and its interrupt, and starts the System Tick Timer.
|
||||||
|
Counter is in free running mode to generate periodic interrupts.
|
||||||
|
|
||||||
|
\param [in] ticks Number of ticks between two interrupts.
|
||||||
|
|
||||||
|
\return 0 Function succeeded.
|
||||||
|
\return 1 Function failed.
|
||||||
|
|
||||||
|
\note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
|
||||||
|
function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
|
||||||
|
must contain a vendor-specific implementation of this function.
|
||||||
|
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
|
||||||
|
{
|
||||||
|
if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
|
||||||
|
|
||||||
|
SysTick->LOAD = ticks - 1; /* set reload register */
|
||||||
|
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
|
||||||
|
SysTick->VAL = 0; /* Load the SysTick Counter Value */
|
||||||
|
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
|
||||||
|
SysTick_CTRL_TICKINT_Msk |
|
||||||
|
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
|
||||||
|
return (0); /* Function successful */
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_SysTickFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_SC000_H_DEPENDANT */
|
||||||
|
|
||||||
|
#endif /* __CMSIS_GENERIC */
|
||||||
1630
F1-nolib/inc/cm/core_sc300.h
Normal file
1630
F1-nolib/inc/cm/core_sc300.h
Normal file
File diff suppressed because it is too large
Load Diff
393
F1-nolib/inc/ld/devices.data
Normal file
393
F1-nolib/inc/ld/devices.data
Normal file
@ -0,0 +1,393 @@
|
|||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Device chip tree definition file.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013 Frantisek Burian <Bufran@seznam.cz>
|
||||||
|
# Copyright (C) 2013 Werner Almesberger <wpwrak>
|
||||||
|
#
|
||||||
|
# Line description:
|
||||||
|
# <pattern> <parent> (<data> ...)
|
||||||
|
#
|
||||||
|
# <pattern>: is the pattern for the chip description to be searched for.
|
||||||
|
# The case of the pattern string is ignored.
|
||||||
|
# Pattern match symbols:
|
||||||
|
# ? - matches exactly one character
|
||||||
|
# * - matches none or more characters
|
||||||
|
# + - matches single or more characters
|
||||||
|
#
|
||||||
|
# <parent>: is the parent group name, where the search will continue.
|
||||||
|
# There are special parents names that controls traversing:
|
||||||
|
# "END" - Exit traversal.
|
||||||
|
# "+" - Don't change the parent. Use for split long line to two.
|
||||||
|
#
|
||||||
|
# <data>: space-separated list of preprocessor symbols supplied to the linker.
|
||||||
|
# -D option name is automatically prepended to each symbol definition
|
||||||
|
#
|
||||||
|
# All lines starting with # symbol are treated as Comments
|
||||||
|
#
|
||||||
|
# Recommended tree hierarchy:
|
||||||
|
#
|
||||||
|
# <device name> <family group> <device specific params>
|
||||||
|
# +- <family group> <family> <family group specific params>
|
||||||
|
# +- <family> <architecture> <device family specific params>
|
||||||
|
# +- <architecture> END <architecture specific params>
|
||||||
|
#
|
||||||
|
# You can split the long line into two or more by using "+" in the parent field,
|
||||||
|
# and defining same regex with appropriate parent on the next line. Example:
|
||||||
|
#
|
||||||
|
# device + PARAM1=aaa PARAM2=bbbb PARAM3=ccc PARAM4=dddd PARAM5=eeee
|
||||||
|
# device parent PARAM6=ffff PARAM7=gggg PARAM8=hhhh
|
||||||
|
# parent END
|
||||||
|
#
|
||||||
|
# The order of the lines is important. After the regex match, its parent will
|
||||||
|
# be used for match on the next line. If two regexp lines matches input, only
|
||||||
|
# the first will be evaluated, except special group definition "+"
|
||||||
|
#
|
||||||
|
# The regex matches entire sym
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
#
|
||||||
|
# --- devices.data file ---
|
||||||
|
# stm32f05[01]?4* stm32f0 ROM=16K RAM=4K
|
||||||
|
# stm32f0 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000
|
||||||
|
# stm32 END
|
||||||
|
#
|
||||||
|
# --- queried chip name ---
|
||||||
|
# stm32f051c8t6
|
||||||
|
#
|
||||||
|
# --- output of the awk script ---
|
||||||
|
# -DROM=16K -DRAM=4K -DROM_OFF=0x08000000 -DRAM_OFF=0x20000000
|
||||||
|
#
|
||||||
|
# The generated linker script file will contain sections rom and ram with
|
||||||
|
# appropriate initialization code, specified in linker file source linker.ld.S
|
||||||
|
#
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# the STM32 chips
|
||||||
|
|
||||||
|
stm32f03[01]?4* stm32f0 ROM=16K RAM=4K
|
||||||
|
stm32f03[01]?6* stm32f0 ROM=32K RAM=4K
|
||||||
|
stm32f030?8* stm32f0 ROM=64K RAM=8K
|
||||||
|
stm32f050?4* stm32f0 ROM=16K RAM=4K
|
||||||
|
stm32f050?6* stm32f0 ROM=32K RAM=4K
|
||||||
|
stm32f051?4* stm32f0 ROM=16K RAM=8K
|
||||||
|
stm32f051?6* stm32f0 ROM=32K RAM=8K
|
||||||
|
stm32f051?8* stm32f0 ROM=64K RAM=8K
|
||||||
|
stm32f072?8* stm32f0 ROM=64K RAM=16K
|
||||||
|
stm32f07[12]?B* stm32f0 ROM=128K RAM=16K
|
||||||
|
|
||||||
|
stm32f10[012]?4* stm32f1 ROM=16K RAM=4K
|
||||||
|
stm32f103?4* stm32f1 ROM=16K RAM=6K
|
||||||
|
stm32f100?6* stm32f1 ROM=32K RAM=4K
|
||||||
|
stm32f103?6* stm32f1 ROM=32K RAM=10K
|
||||||
|
stm32f10[12]?6* stm32f1 ROM=32K RAM=6K
|
||||||
|
stm32f100?8* stm32f1 ROM=64K RAM=8K
|
||||||
|
stm32f10[12]?8* stm32f1 ROM=64K RAM=10K
|
||||||
|
stm32f103?8* stm32f1 ROM=64K RAM=20K
|
||||||
|
stm32f100?b* stm32f1 ROM=128K RAM=8K
|
||||||
|
stm32f10[12]?b* stm32f1 ROM=128K RAM=16K
|
||||||
|
stm32f103?b* stm32f1 ROM=128K RAM=20K
|
||||||
|
stm32f10[57]?b* stm32f1 ROM=128K RAM=64K
|
||||||
|
stm32f100?c* stm32f1 ROM=256K RAM=24K
|
||||||
|
stm32f101?c* stm32f1 ROM=256K RAM=32K
|
||||||
|
stm32f103?c* stm32f1 ROM=256K RAM=48K
|
||||||
|
stm32f10[57]?c* stm32f1 ROM=256K RAM=64K
|
||||||
|
stm32f100?d* stm32f1 ROM=384K RAM=32K
|
||||||
|
stm32f101?d* stm32f1 ROM=384K RAM=48K
|
||||||
|
stm32f103?d* stm32f1 ROM=384K RAM=64K
|
||||||
|
stm32f100?e* stm32f1 ROM=512K RAM=32K
|
||||||
|
stm32f101?e* stm32f1 ROM=512K RAM=48K
|
||||||
|
stm32f103?e* stm32f1 ROM=512K RAM=64K
|
||||||
|
stm32f100?f* stm32f1 ROM=768K RAM=80K
|
||||||
|
stm32f103?f* stm32f1 ROM=768K RAM=96K
|
||||||
|
stm32f100?g* stm32f1 ROM=1024K RAM=80K
|
||||||
|
stm32f103?g* stm32f1 ROM=1024K RAM=96K
|
||||||
|
|
||||||
|
stm32f205?b* stm32f2 ROM=128K RAM=64K
|
||||||
|
stm32f205?c* stm32f2 ROM=256K RAM=96K
|
||||||
|
stm32f207?c* stm32f2 ROM=256K RAM=128K
|
||||||
|
stm32f2[01][57]?e* stm32f2 ROM=512K RAM=128K
|
||||||
|
stm32f20[57]?f* stm32f2 ROM=768K RAM=128K
|
||||||
|
stm32f2[01][57]?g* stm32f2 ROM=1024K RAM=128K
|
||||||
|
|
||||||
|
stm32f302?b* stm32f3ccm ROM=128K RAM=24K CCM=8K
|
||||||
|
stm32f302?c* stm32f3ccm ROM=256K RAM=32K CCM=8K
|
||||||
|
stm32f303?b* stm32f3ccm ROM=128K RAM=40K CCM=8K
|
||||||
|
stm32f3[01]3?c* stm32f3ccm ROM=256K RAM=48K CCM=8K
|
||||||
|
stm32f373?8* stm32f3 ROM=64K RAM=16K
|
||||||
|
stm32f373?b* stm32f3 ROM=128K RAM=24K
|
||||||
|
stm32f3[78]3?8* stm32f3 ROM=256K RAM=32K
|
||||||
|
|
||||||
|
stm32f401?b* stm32f4 ROM=128K RAM=64K
|
||||||
|
stm32f401?c* stm32f4 ROM=256K RAM=64K
|
||||||
|
stm32f401?d* stm32f4 ROM=512K RAM=96K
|
||||||
|
stm32f401?e* stm32f4 ROM=384K RAM=96K
|
||||||
|
stm32f4[01][57]?e* stm32f4ccm ROM=512K RAM=128K CCM=64K
|
||||||
|
stm32f4[01][57]?g* stm32f4ccm ROM=1024K RAM=128K CCM=64K
|
||||||
|
stm32f4[23][79]?g* stm32f4ccm ROM=1024K RAM=192K CCM=64K
|
||||||
|
stm32f4[23][79]?i* stm32f4ccm ROM=2048K RAM=192K CCM=64K
|
||||||
|
|
||||||
|
stm32l0???6* stm32l0 ROM=32K RAM=8K
|
||||||
|
stm32l0???8* stm32l0 ROM=64K RAM=8K
|
||||||
|
|
||||||
|
stm32l100?6* stm32l1 ROM=32K RAM=4K
|
||||||
|
stm32l100?8* stm32l1 ROM=64K RAM=8K
|
||||||
|
stm32l100?b* stm32l1 ROM=128K RAM=10K
|
||||||
|
stm32l100?c* stm32l1 ROM=256K RAM=16K
|
||||||
|
stm32l15[12]?6* stm32l1eep ROM=32K RAM=10K EEP=4K
|
||||||
|
stm32l15[12]?8* stm32l1eep ROM=64K RAM=10K EEP=4K
|
||||||
|
stm32l15[12]?b* stm32l1eep ROM=128K RAM=16K EEP=4K
|
||||||
|
stm32l15[12]?c* stm32l1eep ROM=256K RAM=32K EEP=8K
|
||||||
|
stm32l15[12]?d* stm32l1eep ROM=384K RAM=48K EEP=12K
|
||||||
|
stm32l162?c* stm32l1eep ROM=256K RAM=32K EEP=8K
|
||||||
|
stm32l162?d* stm32l1eep ROM=384K RAM=48K EEP=12K
|
||||||
|
|
||||||
|
stm32ts60 stm32t ROM=32K RAM=10K
|
||||||
|
|
||||||
|
stm32w108c8 stm32w ROM=64K RAM=8K
|
||||||
|
stm32w108?b stm32w ROM=128K RAM=8K
|
||||||
|
stm32w108cz stm32w ROM=192K RAM=12K
|
||||||
|
stm32w108cc stm32w ROM=256K RAM=16K
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# the SAM3 chips
|
||||||
|
|
||||||
|
sam3a4* sam3a ROM=256K RAM=32K RAM1=32K
|
||||||
|
sam3a8* sam3a ROM=512K RAM=64K RAM1=32K
|
||||||
|
|
||||||
|
sam3n00* sam3n ROM=16K RAM=4K
|
||||||
|
sam3n0* sam3n ROM=32K RAM=8K
|
||||||
|
sam3n1* sam3n ROM=64K RAM=8K
|
||||||
|
sam3n2* sam3n ROM=128K RAM=16K
|
||||||
|
sam3n4* sam3n ROM=256K RAM=24K
|
||||||
|
|
||||||
|
sam3s1* sam3s ROM=64K RAM=16K
|
||||||
|
sam3s2* sam3s ROM=128K RAM=32K
|
||||||
|
sam3s4* sam3s ROM=256K RAM=48K
|
||||||
|
sam3s8* sam3s ROM=512K RAM=64K
|
||||||
|
sam3sd8* sam3s ROM=512K RAM=64K
|
||||||
|
|
||||||
|
sam3u1* sam3u ROM=64K RAM=8K RAM1=8K
|
||||||
|
sam3u2* sam3u ROM=128K RAM=16K RAM1=16K
|
||||||
|
sam3u4* sam3u ROM=265K RAM=32K RAM1=16K
|
||||||
|
|
||||||
|
sam3x4c* sam3x ROM=256K RAM=32K RAM1=32K
|
||||||
|
sam3x4e* sam3xnfc ROM=256K RAM=32K RAM1=32K
|
||||||
|
sam3x8c* sam3x ROM=512K RAM=64K RAM1=32K
|
||||||
|
sam3x8e* sam3xnfc ROM=512K RAM=64K RAM1=32K
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# the lpc chips
|
||||||
|
|
||||||
|
lpc1311* lpc13 ROM=8K RAM=4K
|
||||||
|
lpc1313* lpc13 ROM=32K RAM=8K
|
||||||
|
lpc1342* lpc13 ROM=16K RAM=4K
|
||||||
|
lpc1343* lpc13 ROM=32K RAM=8K
|
||||||
|
lpc1315* lpc13u ROM=32K RAM=8K
|
||||||
|
lpc1316* lpc13u ROM=48K RAM=8K
|
||||||
|
lpc1317* lpc13u ROM=64K RAM=8K RAM1=2K
|
||||||
|
lpc1345* lpc13u ROM=32K RAM=8K USBRAM=2K
|
||||||
|
lpc1346* lpc13u ROM=48K RAM=8K USBRAM=2K
|
||||||
|
lpc1346* lpc13u ROM=64K RAM=8K USBRAM=2K RAM1=2K
|
||||||
|
|
||||||
|
lpc1751* lpc175x ROM=32K RAM=8K
|
||||||
|
lpc1752* lpc175x ROM=64K RAM=16K
|
||||||
|
lpc1754* lpc175x ROM=128K RAM=16K RAM1=16K
|
||||||
|
lpc1756* lpc175x ROM=256K RAM=16K RAM1=16K
|
||||||
|
lpc1758* lpc175x ROM=512K RAM=32K RAM1=16K RAM2=16K
|
||||||
|
lpc1759* lpc175x ROM=512K RAM=32K RAM1=16K RAM2=16K
|
||||||
|
lpc1763* lpc176x ROM=256K RAM=32K RAM1=16K RAM2=16K
|
||||||
|
lpc1764* lpc176x ROM=128K RAM=16K RAM1=16K
|
||||||
|
lpc1765* lpc176x ROM=256K RAM=32K RAM1=16K RAM2=16K
|
||||||
|
lpc1766* lpc176x ROM=256K RAM=32K RAM1=16K RAM2=16K
|
||||||
|
lpc1767* lpc176x ROM=512K RAM=32K RAM1=16K RAM2=16K
|
||||||
|
lpc1768* lpc176x ROM=512K RAM=32K RAM1=16K RAM2=16K
|
||||||
|
lpc1769* lpc176x ROM=512K RAM=32K RAM1=16K RAM2=16K
|
||||||
|
lpc1774* lpc177x ROM=128K RAM=32K RAM1=8K
|
||||||
|
lpc1776* lpc177x ROM=256K RAM=64K RAM1=16K
|
||||||
|
lpc1777* lpc177x ROM=512K RAM=64K RAM1=16K RAM2=16K
|
||||||
|
lpc1778* lpc177x ROM=512K RAM=64K RAM1=16K RAM2=16K
|
||||||
|
lpc1785* lpc178x ROM=256K RAM=64K RAM1=16K
|
||||||
|
lpc1786* lpc178x ROM=256K RAM=64K RAM1=16K
|
||||||
|
lpc1787* lpc178x ROM=512K RAM=64K RAM1=16K RAM2=16K
|
||||||
|
lpc1788* lpc178x ROM=512K RAM=64K RAM1=16K RAM2=16K
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# the efm32 chips
|
||||||
|
|
||||||
|
# Zero Gecko
|
||||||
|
efm32zg???f4 efm32zg ROM=4K RAM=2K
|
||||||
|
efm32zg???f8 efm32zg ROM=8K RAM=2K
|
||||||
|
efm32zg???f16 efm32zg ROM=16K RAM=4K
|
||||||
|
efm32zg???f32 efm32zg ROM=32K RAM=4K
|
||||||
|
|
||||||
|
# Tiny Gecko
|
||||||
|
efm32tg108f4 efm32tg ROM=4K RAM=1K
|
||||||
|
efm32tg110f4 efm32tg ROM=4K RAM=2K
|
||||||
|
efm32tg???f8 efm32tg ROM=8K RAM=2K
|
||||||
|
efm32tg???f16 efm32tg ROM=16K RAM=4K
|
||||||
|
efm32tg???f32 efm32tg ROM=32K RAM=4K
|
||||||
|
|
||||||
|
# Gecko
|
||||||
|
efm32g200f16 efm32g ROM=16K RAM=8K
|
||||||
|
efm32g???f32 efm32g ROM=32K RAM=8K
|
||||||
|
efm32g???f64 efm32g ROM=64K RAM=16K
|
||||||
|
efm32g???f128 efm32g ROM=128K RAM=16K
|
||||||
|
|
||||||
|
# Large Gecko
|
||||||
|
efm32lg???f64 efm32lg ROM=64K RAM=32K
|
||||||
|
efm32lg???f128 efm32lg ROM=128K RAM=32K
|
||||||
|
efm32lg???f256 efm32lg ROM=256K RAM=32K
|
||||||
|
|
||||||
|
# Giant Gecko
|
||||||
|
efm32gg???f512 efm32gg ROM=512K RAM=128K
|
||||||
|
efm32gg???f1024 efm32gg ROM=1024K RAM=128K
|
||||||
|
|
||||||
|
# Wonder Gecko
|
||||||
|
efm32wg???f64 efm32gg ROM=64K RAM=32K
|
||||||
|
efm32wg???f128 efm32gg ROM=128K RAM=32K
|
||||||
|
efm32wg???f256 efm32gg ROM=256K RAM=32K
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# the TI cortex M3 chips
|
||||||
|
|
||||||
|
lm3s101 lm3sandstorm ROM=8K RAM=2K
|
||||||
|
lm3s102 lm3sandstorm ROM=8K RAM=2K
|
||||||
|
|
||||||
|
lm3s300 lm3sandstorm ROM=16K RAM=4K
|
||||||
|
lm3s301 lm3sandstorm ROM=16K RAM=2K
|
||||||
|
lm3s308 lm3sandstorm ROM=16K RAM=4K
|
||||||
|
lm3s310 lm3sandstorm ROM=16K RAM=4K
|
||||||
|
lm3s315 lm3sandstorm ROM=16K RAM=4K
|
||||||
|
lm3s316 lm3sandstorm ROM=16K RAM=4K
|
||||||
|
lm3s317 lm3sandstorm ROM=16K RAM=4K
|
||||||
|
lm3s328 lm3sandstorm ROM=16K RAM=4K
|
||||||
|
lm3s600 lm3sandstorm ROM=32K RAM=8K
|
||||||
|
lm3s601 lm3sandstorm ROM=32K RAM=8K
|
||||||
|
lm3s608 lm3sandstorm ROM=32K RAM=8K
|
||||||
|
lm3s610 lm3sandstorm ROM=32K RAM=8K
|
||||||
|
lm3s611 lm3sandstorm ROM=32K RAM=8K
|
||||||
|
lm3s612 lm3sandstorm ROM=32K RAM=8K
|
||||||
|
lm3s613 lm3sandstorm ROM=32K RAM=8K
|
||||||
|
lm3s615 lm3sandstorm ROM=32K RAM=8K
|
||||||
|
lm3s617 lm3sandstorm ROM=32K RAM=8K
|
||||||
|
lm3s618 lm3sandstorm ROM=32K RAM=8K
|
||||||
|
lm3s628 lm3sandstorm ROM=32K RAM=8K
|
||||||
|
lm3s800 lm3sandstorm ROM=64K RAM=8K
|
||||||
|
lm3s801 lm3sandstorm ROM=64K RAM=8K
|
||||||
|
lm3s808 lm3sandstorm ROM=64K RAM=8K
|
||||||
|
lm3s811 lm3sandstorm ROM=64K RAM=8K
|
||||||
|
lm3s812 lm3sandstorm ROM=64K RAM=8K
|
||||||
|
lm3s815 lm3sandstorm ROM=64K RAM=8K
|
||||||
|
lm3s817 lm3sandstorm ROM=64K RAM=8K
|
||||||
|
lm3s818 lm3sandstorm ROM=64K RAM=8K
|
||||||
|
lm3s828 lm3sandstorm ROM=64K RAM=8K
|
||||||
|
|
||||||
|
lm3s1110 lm3fury ROM=64K RAM=16K
|
||||||
|
lm3s1133 lm3fury ROM=64K RAM=16K
|
||||||
|
lm3s1138 lm3fury ROM=64K RAM=16K
|
||||||
|
lm3s1150 lm3fury ROM=64K RAM=16K
|
||||||
|
lm3s1162 lm3fury ROM=64K RAM=16K
|
||||||
|
lm3s1165 lm3fury ROM=64K RAM=16K
|
||||||
|
lm3s1332 lm3fury ROM=96K RAM=16K
|
||||||
|
lm3s1435 lm3fury ROM=96K RAM=32K
|
||||||
|
lm3s1439 lm3fury ROM=96K RAM=32K
|
||||||
|
lm3s1512 lm3fury ROM=96K RAM=64K
|
||||||
|
lm3s1538 lm3fury ROM=96K RAM=64K
|
||||||
|
lm3s1601 lm3fury ROM=128K RAM=32K
|
||||||
|
lm3s1607 lm3fury ROM=128K RAM=32K
|
||||||
|
lm3s1608 lm3fury ROM=128K RAM=32K
|
||||||
|
lm3s1620 lm3fury ROM=128K RAM=32K
|
||||||
|
lm3s8962 lm3fury ROM=256K RAM=64K
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# the TI cortex R4F chips
|
||||||
|
|
||||||
|
rm46l852* rm46l ROM=1280K RAM=192K
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
################################################################################
|
||||||
|
################################################################################
|
||||||
|
# the STM32 family groups
|
||||||
|
|
||||||
|
stm32f3ccm stm32f3 CCM_OFF=0x10000000
|
||||||
|
stm32f4ccm stm32f4 CCM_OFF=0x10000000
|
||||||
|
stm32l1eep stm32l1 EEP_OFF=0x08080000
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# the SAM3 family groups
|
||||||
|
sam3xnfc sam3x NFCRAM=4K NFCRAM_OFF=0x20100000
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# the lpc family groups
|
||||||
|
|
||||||
|
|
||||||
|
lpc13u lpc13 USBRAM_OFF=0x20004000
|
||||||
|
|
||||||
|
lpc17[56]x lpc17 RAM1_OFF=0x2007C000 RAM2_OFF=0x20080000
|
||||||
|
lpc17[78]x lpc17 RAM1_OFF=0x20000000 RAM2_OFF=0x20040000
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
################################################################################
|
||||||
|
################################################################################
|
||||||
|
# the STM32 families
|
||||||
|
|
||||||
|
stm32f0 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m0 -mthumb -DSTM32F0 -lopencm3_stm32f0 -msoft-float
|
||||||
|
stm32f1 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m3 -mthumb -DSTM32F1 -lopencm3_stm32f1 -msoft-float
|
||||||
|
stm32f2 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m3 -mthumb -DSTM32F2 -lopencm3_stm32f2 -msoft-float
|
||||||
|
stm32f3 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m4 -mthumb -DSTM32F3 -lopencm3_stm32f3 -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
|
stm32f4 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m4 -mthumb -DSTM32F4 -lopencm3_stm32f4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
|
stm32l0 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m0 -mthumb -DSTM32L0 -lopencm3_stm32l0 -msoft-float
|
||||||
|
stm32l1 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m3 -mthumb -DSTM32L1 -lopencm3_stm32l1 -msoft-float
|
||||||
|
stm32w stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m3 -mthumb
|
||||||
|
stm32t stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m3 -mthumb
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# the SAM3 families
|
||||||
|
|
||||||
|
sam3a sam3 ROM_OFF=0x00080000 RAM_OFF=0x20000000 RAM1_OFF=0x20080000
|
||||||
|
sam3n sam3 ROM_OFF=0x00400000 RAM_OFF=0x20000000
|
||||||
|
sam3s sam3 ROM_OFF=0x00400000 RAM_OFF=0x20000000
|
||||||
|
sam3u sam3 ROM_OFF=0x00080000 RAM_OFF=0x20000000 RAM1_OFF=0x20080000 NFCRAM=4K NFCRAM_OFF=0x20100000
|
||||||
|
sam3x sam3 ROM_OFF=0x00080000 RAM_OFF=0x20000000 RAM1_OFF=0x20080000
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# the lpc families
|
||||||
|
|
||||||
|
lpc13 lpc ROM_OFF=0x00000000 RAM_OFF=0x10000000 RAM1_OFF=0x20000000
|
||||||
|
lpc17 lpc ROM_OFF=0x00000000 RAM_OFF=0x10000000
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# the efm32 Gecko families
|
||||||
|
|
||||||
|
efm32zg efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000
|
||||||
|
efm32tg efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000
|
||||||
|
efm32g efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000
|
||||||
|
efm32lg efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000
|
||||||
|
efm32gg efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000
|
||||||
|
efm32wg efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Cortex LM3 families
|
||||||
|
|
||||||
|
lm3fury lm3 ROM_OFF=0x00000000 RAM_OFF=0x20000000
|
||||||
|
lm3sandstorm lm3 ROM_OFF=0x00000000 RAM_OFF=0x20000000
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Cortex R4F families
|
||||||
|
|
||||||
|
rm46l rm4 ROM_OFF=0x00000000 RAM_OFF=0x08000000 RAM1_OFF=0x08400000
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
################################################################################
|
||||||
|
################################################################################
|
||||||
|
# the architectures
|
||||||
|
|
||||||
|
stm32 END
|
||||||
|
sam3 END
|
||||||
|
lpc END
|
||||||
|
efm32 END
|
||||||
|
lm3 END
|
||||||
|
rm4 END
|
||||||
|
|
||||||
106
F1-nolib/inc/ld/stm32f01234.ld
Normal file
106
F1-nolib/inc/ld/stm32f01234.ld
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Generic linker script for STM32 targets using libopencm3. */
|
||||||
|
|
||||||
|
/* Memory regions must be defined in the ld script which includes this one. */
|
||||||
|
|
||||||
|
/* Enforce emmition of the vector table. */
|
||||||
|
EXTERN (vector_table)
|
||||||
|
|
||||||
|
/* Define the entry point of the output file. */
|
||||||
|
ENTRY(reset_handler)
|
||||||
|
|
||||||
|
/* Define sections. */
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text : {
|
||||||
|
*(.vectors) /* Vector table */
|
||||||
|
*(.text*) /* Program code */
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(.rodata*) /* Read-only data */
|
||||||
|
. = ALIGN(4);
|
||||||
|
} >rom
|
||||||
|
|
||||||
|
/* C++ Static constructors/destructors, also used for __attribute__
|
||||||
|
* ((constructor)) and the likes */
|
||||||
|
.preinit_array : {
|
||||||
|
. = ALIGN(4);
|
||||||
|
__preinit_array_start = .;
|
||||||
|
KEEP (*(.preinit_array))
|
||||||
|
__preinit_array_end = .;
|
||||||
|
} >rom
|
||||||
|
.init_array : {
|
||||||
|
. = ALIGN(4);
|
||||||
|
__init_array_start = .;
|
||||||
|
KEEP (*(SORT(.init_array.*)))
|
||||||
|
KEEP (*(.init_array))
|
||||||
|
__init_array_end = .;
|
||||||
|
} >rom
|
||||||
|
.fini_array : {
|
||||||
|
. = ALIGN(4);
|
||||||
|
__fini_array_start = .;
|
||||||
|
KEEP (*(.fini_array))
|
||||||
|
KEEP (*(SORT(.fini_array.*)))
|
||||||
|
__fini_array_end = .;
|
||||||
|
} >rom
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Another section used by C++ stuff, appears when using newlib with
|
||||||
|
* 64bit (long long) printf support
|
||||||
|
*/
|
||||||
|
.ARM.extab : {
|
||||||
|
*(.ARM.extab*)
|
||||||
|
} >rom
|
||||||
|
.ARM.exidx : {
|
||||||
|
__exidx_start = .;
|
||||||
|
*(.ARM.exidx*)
|
||||||
|
__exidx_end = .;
|
||||||
|
} >rom
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
_etext = .;
|
||||||
|
|
||||||
|
.data : {
|
||||||
|
_data = .;
|
||||||
|
*(.data*) /* Read-write initialized data */
|
||||||
|
. = ALIGN(4);
|
||||||
|
_edata = .;
|
||||||
|
} >ram AT >rom
|
||||||
|
_data_loadaddr = LOADADDR(.data);
|
||||||
|
|
||||||
|
.bss : {
|
||||||
|
*(.bss*) /* Read-write zero initialized data */
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(4);
|
||||||
|
_ebss = .;
|
||||||
|
} >ram
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The .eh_frame section appears to be used for C++ exception handling.
|
||||||
|
* You may need to fix this if you're using C++.
|
||||||
|
*/
|
||||||
|
/DISCARD/ : { *(.eh_frame) }
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
end = .;
|
||||||
|
}
|
||||||
|
|
||||||
|
PROVIDE(_stack = ORIGIN(ram) + LENGTH(ram));
|
||||||
|
|
||||||
869
F1-nolib/inc/startup/vector.c
Normal file
869
F1-nolib/inc/startup/vector.c
Normal file
@ -0,0 +1,869 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>,
|
||||||
|
* Copyright (C) 2012 chrysn <chrysn@fsfe.org>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
#include "vector.h"
|
||||||
|
|
||||||
|
/* Initialization template for the interrupt vector table. This definition is
|
||||||
|
* used by the startup code generator (vector.c) to set the initial values for
|
||||||
|
* the interrupt handling routines to the chip family specific _isr weak
|
||||||
|
* symbols. */
|
||||||
|
#if defined STM32F0
|
||||||
|
#include "stm32f0xx.h"
|
||||||
|
#define NVIC_IRQ_COUNT 32
|
||||||
|
#define IRQ_HANDLERS \
|
||||||
|
wwdg_isr, \
|
||||||
|
pvd_isr, \
|
||||||
|
rtc_isr, \
|
||||||
|
flash_isr, \
|
||||||
|
rcc_isr, \
|
||||||
|
exti0_1_isr, \
|
||||||
|
exti2_3_isr, \
|
||||||
|
exti4_15_isr, \
|
||||||
|
tsc_isr, \
|
||||||
|
dma1_channel1_isr, \
|
||||||
|
dma1_channel2_3_isr, \
|
||||||
|
dma1_channel4_5_isr, \
|
||||||
|
adc_comp_isr, \
|
||||||
|
tim1_brk_up_trg_com_isr, \
|
||||||
|
tim1_cc_isr, \
|
||||||
|
tim2_isr, \
|
||||||
|
tim3_isr, \
|
||||||
|
tim6_dac_isr, \
|
||||||
|
tim7_isr, \
|
||||||
|
tim14_isr, \
|
||||||
|
tim15_isr, \
|
||||||
|
tim16_isr, \
|
||||||
|
tim17_isr, \
|
||||||
|
i2c1_isr, \
|
||||||
|
i2c2_isr, \
|
||||||
|
spi1_isr, \
|
||||||
|
spi2_isr, \
|
||||||
|
usart1_isr, \
|
||||||
|
usart2_isr, \
|
||||||
|
usart3_4_isr, \
|
||||||
|
cec_can_isr, \
|
||||||
|
usb_isr
|
||||||
|
#elif defined STM32F1
|
||||||
|
#include "stm32f10x.h"
|
||||||
|
#define NVIC_IRQ_COUNT 68
|
||||||
|
#define IRQ_HANDLERS \
|
||||||
|
wwdg_isr, \
|
||||||
|
pvd_isr, \
|
||||||
|
tamper_isr, \
|
||||||
|
rtc_isr, \
|
||||||
|
flash_isr, \
|
||||||
|
rcc_isr, \
|
||||||
|
exti0_isr, \
|
||||||
|
exti1_isr, \
|
||||||
|
exti2_isr, \
|
||||||
|
exti3_isr, \
|
||||||
|
exti4_isr, \
|
||||||
|
dma1_channel1_isr, \
|
||||||
|
dma1_channel2_isr, \
|
||||||
|
dma1_channel3_isr, \
|
||||||
|
dma1_channel4_isr, \
|
||||||
|
dma1_channel5_isr, \
|
||||||
|
dma1_channel6_isr, \
|
||||||
|
dma1_channel7_isr, \
|
||||||
|
adc1_2_isr, \
|
||||||
|
usb_hp_can_tx_isr, \
|
||||||
|
usb_lp_can_rx0_isr, \
|
||||||
|
can_rx1_isr, \
|
||||||
|
can_sce_isr, \
|
||||||
|
exti9_5_isr, \
|
||||||
|
tim1_brk_isr, \
|
||||||
|
tim1_up_isr, \
|
||||||
|
tim1_trg_com_isr, \
|
||||||
|
tim1_cc_isr, \
|
||||||
|
tim2_isr, \
|
||||||
|
tim3_isr, \
|
||||||
|
tim4_isr, \
|
||||||
|
i2c1_ev_isr, \
|
||||||
|
i2c1_er_isr, \
|
||||||
|
i2c2_ev_isr, \
|
||||||
|
i2c2_er_isr, \
|
||||||
|
spi1_isr, \
|
||||||
|
spi2_isr, \
|
||||||
|
usart1_isr, \
|
||||||
|
usart2_isr, \
|
||||||
|
usart3_isr, \
|
||||||
|
exti15_10_isr, \
|
||||||
|
rtc_alarm_isr, \
|
||||||
|
usb_wakeup_isr, \
|
||||||
|
tim8_brk_isr, \
|
||||||
|
tim8_up_isr, \
|
||||||
|
tim8_trg_com_isr, \
|
||||||
|
tim8_cc_isr, \
|
||||||
|
adc3_isr, \
|
||||||
|
fsmc_isr, \
|
||||||
|
sdio_isr, \
|
||||||
|
tim5_isr, \
|
||||||
|
spi3_isr, \
|
||||||
|
uart4_isr, \
|
||||||
|
uart5_isr, \
|
||||||
|
tim6_isr, \
|
||||||
|
tim7_isr, \
|
||||||
|
dma2_channel1_isr, \
|
||||||
|
dma2_channel2_isr, \
|
||||||
|
dma2_channel3_isr, \
|
||||||
|
dma2_channel4_5_isr, \
|
||||||
|
dma2_channel5_isr, \
|
||||||
|
eth_isr, \
|
||||||
|
eth_wkup_isr, \
|
||||||
|
can2_tx_isr, \
|
||||||
|
can2_rx0_isr, \
|
||||||
|
can2_rx1_isr, \
|
||||||
|
can2_sce_isr, \
|
||||||
|
otg_fs_isr
|
||||||
|
#elif defined STM32F2
|
||||||
|
#define NVIC_IRQ_COUNT 81
|
||||||
|
#define IRQ_HANDLERS \
|
||||||
|
nvic_wwdg_isr, \
|
||||||
|
pvd_isr, \
|
||||||
|
tamp_stamp_isr, \
|
||||||
|
rtc_wkup_isr, \
|
||||||
|
flash_isr, \
|
||||||
|
rcc_isr, \
|
||||||
|
exti0_isr, \
|
||||||
|
exti1_isr, \
|
||||||
|
exti2_isr, \
|
||||||
|
exti3_isr, \
|
||||||
|
exti4_isr, \
|
||||||
|
dma1_stream0_isr, \
|
||||||
|
dma1_stream1_isr, \
|
||||||
|
dma1_stream2_isr, \
|
||||||
|
dma1_stream3_isr, \
|
||||||
|
dma1_stream4_isr, \
|
||||||
|
dma1_stream5_isr, \
|
||||||
|
dma1_stream6_isr, \
|
||||||
|
adc_isr, \
|
||||||
|
can1_tx_isr, \
|
||||||
|
can1_rx0_isr, \
|
||||||
|
can1_rx1_isr, \
|
||||||
|
can1_sce_isr, \
|
||||||
|
exti9_5_isr, \
|
||||||
|
tim1_brk_tim9_isr, \
|
||||||
|
tim1_up_tim10_isr, \
|
||||||
|
tim1_trg_com_tim11_isr, \
|
||||||
|
tim1_cc_isr, \
|
||||||
|
tim2_isr, \
|
||||||
|
tim3_isr, \
|
||||||
|
tim4_isr, \
|
||||||
|
i2c1_ev_isr, \
|
||||||
|
i2c1_er_isr, \
|
||||||
|
i2c2_ev_isr, \
|
||||||
|
i2c2_er_isr, \
|
||||||
|
spi1_isr, \
|
||||||
|
spi2_isr, \
|
||||||
|
usart1_isr, \
|
||||||
|
usart2_isr, \
|
||||||
|
usart3_isr, \
|
||||||
|
exti15_10_isr, \
|
||||||
|
rtc_alarm_isr, \
|
||||||
|
usb_fs_wkup_isr, \
|
||||||
|
tim8_brk_tim12_isr, \
|
||||||
|
tim8_up_tim13_isr, \
|
||||||
|
tim8_trg_com_tim14_isr, \
|
||||||
|
tim8_cc_isr, \
|
||||||
|
dma1_stream7_isr, \
|
||||||
|
fsmc_isr, \
|
||||||
|
sdio_isr, \
|
||||||
|
tim5_isr, \
|
||||||
|
spi3_isr, \
|
||||||
|
uart4_isr, \
|
||||||
|
uart5_isr, \
|
||||||
|
tim6_dac_isr, \
|
||||||
|
tim7_isr, \
|
||||||
|
dma2_stream0_isr, \
|
||||||
|
dma2_stream1_isr, \
|
||||||
|
dma2_stream2_isr, \
|
||||||
|
dma2_stream3_isr, \
|
||||||
|
dma2_stream4_isr, \
|
||||||
|
eth_isr, \
|
||||||
|
eth_wkup_isr, \
|
||||||
|
can2_tx_isr, \
|
||||||
|
can2_rx0_isr, \
|
||||||
|
can2_rx1_isr, \
|
||||||
|
can2_sce_isr, \
|
||||||
|
otg_fs_isr, \
|
||||||
|
dma2_stream5_isr, \
|
||||||
|
dma2_stream6_isr, \
|
||||||
|
dma2_stream7_isr, \
|
||||||
|
usart6_isr, \
|
||||||
|
i2c3_ev_isr, \
|
||||||
|
i2c3_er_isr, \
|
||||||
|
otg_hs_ep1_out_isr, \
|
||||||
|
otg_hs_ep1_in_isr, \
|
||||||
|
otg_hs_wkup_isr, \
|
||||||
|
otg_hs_isr, \
|
||||||
|
dcmi_isr, \
|
||||||
|
cryp_isr, \
|
||||||
|
hash_rng_isr
|
||||||
|
|
||||||
|
#elif defined STM32F3
|
||||||
|
#define NVIC_IRQ_COUNT 81
|
||||||
|
#define IRQ_HANDLERS \
|
||||||
|
nvic_wwdg_isr, \
|
||||||
|
pvd_isr, \
|
||||||
|
tamp_stamp_isr, \
|
||||||
|
rtc_wkup_isr, \
|
||||||
|
flash_isr, \
|
||||||
|
rcc_isr, \
|
||||||
|
exti0_isr, \
|
||||||
|
exti1_isr, \
|
||||||
|
exti2_tsc_isr, \
|
||||||
|
exti3_isr, \
|
||||||
|
exti4_isr, \
|
||||||
|
dma1_channel1_isr, \
|
||||||
|
dma1_channel2_isr, \
|
||||||
|
dma1_channel3_isr, \
|
||||||
|
dma1_channel4_isr, \
|
||||||
|
dma1_channel5_isr, \
|
||||||
|
dma1_channel6_isr, \
|
||||||
|
dma1_channel7_isr, \
|
||||||
|
adc1_2_isr, \
|
||||||
|
usb_hp_can1_tx_isr, \
|
||||||
|
usb_lp_can1_rx0_isr, \
|
||||||
|
can1_rx1_isr, \
|
||||||
|
can1_sce_isr, \
|
||||||
|
exti9_5_isr, \
|
||||||
|
tim1_brk_tim15_isr, \
|
||||||
|
tim1_up_tim16_isr, \
|
||||||
|
tim1_trg_com_tim17_isr, \
|
||||||
|
tim1_cc_isr, \
|
||||||
|
tim2_isr, \
|
||||||
|
tim3_isr, \
|
||||||
|
tim4_isr, \
|
||||||
|
i2c1_ev_exti23_isr, \
|
||||||
|
i2c1_er_isr, \
|
||||||
|
i2c2_ev_exti24_isr, \
|
||||||
|
i2c2_er_isr, \
|
||||||
|
spi1_isr, \
|
||||||
|
spi2_isr, \
|
||||||
|
usart1_exti25_isr, \
|
||||||
|
usart2_exti26_isr, \
|
||||||
|
usart3_exti28_isr, \
|
||||||
|
exti15_10_isr, \
|
||||||
|
rtc_alarm_isr, \
|
||||||
|
usb_wkup_a_isr, \
|
||||||
|
tim8_brk_isr, \
|
||||||
|
tim8_up_isr, \
|
||||||
|
tim8_trg_com_isr, \
|
||||||
|
tim8_cc_isr, \
|
||||||
|
adc3_isr, \
|
||||||
|
reserved_1_isr, \
|
||||||
|
reserved_2_isr, \
|
||||||
|
reserved_3_isr, \
|
||||||
|
spi3_isr, \
|
||||||
|
uart4_exti34_isr, \
|
||||||
|
uart5_exti35_isr, \
|
||||||
|
tim6_dac_isr, \
|
||||||
|
tim7_isr, \
|
||||||
|
dma2_channel1_isr, \
|
||||||
|
dma2_channel2_isr, \
|
||||||
|
dma2_channel3_isr, \
|
||||||
|
dma2_channel4_isr, \
|
||||||
|
dma2_channel5_isr, \
|
||||||
|
eth_isr, \
|
||||||
|
reserved_4_isr, \
|
||||||
|
reserved_5_isr, \
|
||||||
|
comp123_isr, \
|
||||||
|
comp456_isr, \
|
||||||
|
comp7_isr, \
|
||||||
|
reserved_6_isr, \
|
||||||
|
reserved_7_isr, \
|
||||||
|
reserved_8_isr, \
|
||||||
|
reserved_9_isr, \
|
||||||
|
reserved_10_isr, \
|
||||||
|
reserved_11_isr, \
|
||||||
|
reserved_12_isr, \
|
||||||
|
usb_hp_isr, \
|
||||||
|
usb_lp_isr, \
|
||||||
|
usb_wkup_isr, \
|
||||||
|
reserved_13_isr, \
|
||||||
|
reserved_14_isr, \
|
||||||
|
reserved_15_isr, \
|
||||||
|
reserved_16_isr
|
||||||
|
|
||||||
|
#elif defined STM32F4
|
||||||
|
#define NVIC_IRQ_COUNT 91
|
||||||
|
#define IRQ_HANDLERS \
|
||||||
|
nvic_wwdg_isr, \
|
||||||
|
pvd_isr, \
|
||||||
|
tamp_stamp_isr, \
|
||||||
|
rtc_wkup_isr, \
|
||||||
|
flash_isr, \
|
||||||
|
rcc_isr, \
|
||||||
|
exti0_isr, \
|
||||||
|
exti1_isr, \
|
||||||
|
exti2_isr, \
|
||||||
|
exti3_isr, \
|
||||||
|
exti4_isr, \
|
||||||
|
dma1_stream0_isr, \
|
||||||
|
dma1_stream1_isr, \
|
||||||
|
dma1_stream2_isr, \
|
||||||
|
dma1_stream3_isr, \
|
||||||
|
dma1_stream4_isr, \
|
||||||
|
dma1_stream5_isr, \
|
||||||
|
dma1_stream6_isr, \
|
||||||
|
adc_isr, \
|
||||||
|
can1_tx_isr, \
|
||||||
|
can1_rx0_isr, \
|
||||||
|
can1_rx1_isr, \
|
||||||
|
can1_sce_isr, \
|
||||||
|
exti9_5_isr, \
|
||||||
|
tim1_brk_tim9_isr, \
|
||||||
|
tim1_up_tim10_isr, \
|
||||||
|
tim1_trg_com_tim11_isr, \
|
||||||
|
tim1_cc_isr, \
|
||||||
|
tim2_isr, \
|
||||||
|
tim3_isr, \
|
||||||
|
tim4_isr, \
|
||||||
|
i2c1_ev_isr, \
|
||||||
|
i2c1_er_isr, \
|
||||||
|
i2c2_ev_isr, \
|
||||||
|
i2c2_er_isr, \
|
||||||
|
spi1_isr, \
|
||||||
|
spi2_isr, \
|
||||||
|
usart1_isr, \
|
||||||
|
usart2_isr, \
|
||||||
|
usart3_isr, \
|
||||||
|
exti15_10_isr, \
|
||||||
|
rtc_alarm_isr, \
|
||||||
|
usb_fs_wkup_isr, \
|
||||||
|
tim8_brk_tim12_isr, \
|
||||||
|
tim8_up_tim13_isr, \
|
||||||
|
tim8_trg_com_tim14_isr, \
|
||||||
|
tim8_cc_isr, \
|
||||||
|
dma1_stream7_isr, \
|
||||||
|
fsmc_isr, \
|
||||||
|
sdio_isr, \
|
||||||
|
tim5_isr, \
|
||||||
|
spi3_isr, \
|
||||||
|
uart4_isr, \
|
||||||
|
uart5_isr, \
|
||||||
|
tim6_dac_isr, \
|
||||||
|
tim7_isr, \
|
||||||
|
dma2_stream0_isr, \
|
||||||
|
dma2_stream1_isr, \
|
||||||
|
dma2_stream2_isr, \
|
||||||
|
dma2_stream3_isr, \
|
||||||
|
dma2_stream4_isr, \
|
||||||
|
eth_isr, \
|
||||||
|
eth_wkup_isr, \
|
||||||
|
can2_tx_isr, \
|
||||||
|
can2_rx0_isr, \
|
||||||
|
can2_rx1_isr, \
|
||||||
|
can2_sce_isr, \
|
||||||
|
otg_fs_isr, \
|
||||||
|
dma2_stream5_isr, \
|
||||||
|
dma2_stream6_isr, \
|
||||||
|
dma2_stream7_isr, \
|
||||||
|
usart6_isr, \
|
||||||
|
i2c3_ev_isr, \
|
||||||
|
i2c3_er_isr, \
|
||||||
|
otg_hs_ep1_out_isr, \
|
||||||
|
otg_hs_ep1_in_isr, \
|
||||||
|
otg_hs_wkup_isr, \
|
||||||
|
otg_hs_isr, \
|
||||||
|
dcmi_isr, \
|
||||||
|
cryp_isr, \
|
||||||
|
hash_rng_isr, \
|
||||||
|
fpu_isr, \
|
||||||
|
uart7_isr, \
|
||||||
|
uart8_isr, \
|
||||||
|
spi4_isr, \
|
||||||
|
spi5_isr, \
|
||||||
|
spi6_isr, \
|
||||||
|
sai1_isr, \
|
||||||
|
lcd_tft_isr, \
|
||||||
|
lcd_tft_err_isr, \
|
||||||
|
dma2d_isr
|
||||||
|
#else
|
||||||
|
#error "Not supported STM32 family"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined STM32F0
|
||||||
|
#pragma weak nmi_handler = null_handler
|
||||||
|
#pragma weak hard_fault_handler = blocking_handler
|
||||||
|
#pragma weak sv_call_handler = null_handler
|
||||||
|
#pragma weak pend_sv_handler = null_handler
|
||||||
|
#pragma weak sys_tick_handler = null_handler
|
||||||
|
|
||||||
|
#pragma weak wwdg_isr = blocking_handler
|
||||||
|
#pragma weak pvd_isr = blocking_handler
|
||||||
|
#pragma weak rtc_isr = blocking_handler
|
||||||
|
#pragma weak flash_isr = blocking_handler
|
||||||
|
#pragma weak rcc_isr = blocking_handler
|
||||||
|
#pragma weak exti0_1_isr = blocking_handler
|
||||||
|
#pragma weak exti2_3_isr = blocking_handler
|
||||||
|
#pragma weak exti4_15_isr = blocking_handler
|
||||||
|
#pragma weak tsc_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel1_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel2_3_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel4_5_isr = blocking_handler
|
||||||
|
#pragma weak adc_comp_isr = blocking_handler
|
||||||
|
#pragma weak tim1_brk_up_trg_com_isr = blocking_handler
|
||||||
|
#pragma weak tim1_cc_isr = blocking_handler
|
||||||
|
#pragma weak tim2_isr = blocking_handler
|
||||||
|
#pragma weak tim3_isr = blocking_handler
|
||||||
|
#pragma weak tim6_dac_isr = blocking_handler
|
||||||
|
#pragma weak tim7_isr = blocking_handler
|
||||||
|
#pragma weak tim14_isr = blocking_handler
|
||||||
|
#pragma weak tim15_isr = blocking_handler
|
||||||
|
#pragma weak tim16_isr = blocking_handler
|
||||||
|
#pragma weak tim17_isr = blocking_handler
|
||||||
|
#pragma weak i2c1_isr = blocking_handler
|
||||||
|
#pragma weak i2c2_isr = blocking_handler
|
||||||
|
#pragma weak spi1_isr = blocking_handler
|
||||||
|
#pragma weak spi2_isr = blocking_handler
|
||||||
|
#pragma weak usart1_isr = blocking_handler
|
||||||
|
#pragma weak usart2_isr = blocking_handler
|
||||||
|
#pragma weak usart3_4_isr = blocking_handler
|
||||||
|
#pragma weak cec_can_isr = blocking_handler
|
||||||
|
#pragma weak usb_isr = blocking_handler
|
||||||
|
|
||||||
|
#elif defined STM32F1
|
||||||
|
#pragma weak wwdg_isr = blocking_handler
|
||||||
|
#pragma weak pvd_isr = blocking_handler
|
||||||
|
#pragma weak tamper_isr = blocking_handler
|
||||||
|
#pragma weak rtc_isr = blocking_handler
|
||||||
|
#pragma weak flash_isr = blocking_handler
|
||||||
|
#pragma weak rcc_isr = blocking_handler
|
||||||
|
#pragma weak exti0_isr = blocking_handler
|
||||||
|
#pragma weak exti1_isr = blocking_handler
|
||||||
|
#pragma weak exti2_isr = blocking_handler
|
||||||
|
#pragma weak exti3_isr = blocking_handler
|
||||||
|
#pragma weak exti4_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel1_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel2_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel3_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel4_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel5_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel6_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel7_isr = blocking_handler
|
||||||
|
#pragma weak adc1_2_isr = blocking_handler
|
||||||
|
#pragma weak usb_hp_can_tx_isr = blocking_handler
|
||||||
|
#pragma weak usb_lp_can_rx0_isr = blocking_handler
|
||||||
|
#pragma weak can_rx1_isr = blocking_handler
|
||||||
|
#pragma weak can_sce_isr = blocking_handler
|
||||||
|
#pragma weak exti9_5_isr = blocking_handler
|
||||||
|
#pragma weak tim1_brk_isr = blocking_handler
|
||||||
|
#pragma weak tim1_up_isr = blocking_handler
|
||||||
|
#pragma weak tim1_trg_com_isr = blocking_handler
|
||||||
|
#pragma weak tim1_cc_isr = blocking_handler
|
||||||
|
#pragma weak tim2_isr = blocking_handler
|
||||||
|
#pragma weak tim3_isr = blocking_handler
|
||||||
|
#pragma weak tim4_isr = blocking_handler
|
||||||
|
#pragma weak i2c1_ev_isr = blocking_handler
|
||||||
|
#pragma weak i2c1_er_isr = blocking_handler
|
||||||
|
#pragma weak i2c2_ev_isr = blocking_handler
|
||||||
|
#pragma weak i2c2_er_isr = blocking_handler
|
||||||
|
#pragma weak spi1_isr = blocking_handler
|
||||||
|
#pragma weak spi2_isr = blocking_handler
|
||||||
|
#pragma weak usart1_isr = blocking_handler
|
||||||
|
#pragma weak usart2_isr = blocking_handler
|
||||||
|
#pragma weak usart3_isr = blocking_handler
|
||||||
|
#pragma weak exti15_10_isr = blocking_handler
|
||||||
|
#pragma weak rtc_alarm_isr = blocking_handler
|
||||||
|
#pragma weak usb_wakeup_isr = blocking_handler
|
||||||
|
#pragma weak tim8_brk_isr = blocking_handler
|
||||||
|
#pragma weak tim8_up_isr = blocking_handler
|
||||||
|
#pragma weak tim8_trg_com_isr = blocking_handler
|
||||||
|
#pragma weak tim8_cc_isr = blocking_handler
|
||||||
|
#pragma weak adc3_isr = blocking_handler
|
||||||
|
#pragma weak fsmc_isr = blocking_handler
|
||||||
|
#pragma weak sdio_isr = blocking_handler
|
||||||
|
#pragma weak tim5_isr = blocking_handler
|
||||||
|
#pragma weak spi3_isr = blocking_handler
|
||||||
|
#pragma weak uart4_isr = blocking_handler
|
||||||
|
#pragma weak uart5_isr = blocking_handler
|
||||||
|
#pragma weak tim6_isr = blocking_handler
|
||||||
|
#pragma weak tim7_isr = blocking_handler
|
||||||
|
#pragma weak dma2_channel1_isr = blocking_handler
|
||||||
|
#pragma weak dma2_channel2_isr = blocking_handler
|
||||||
|
#pragma weak dma2_channel3_isr = blocking_handler
|
||||||
|
#pragma weak dma2_channel4_5_isr = blocking_handler
|
||||||
|
#pragma weak dma2_channel5_isr = blocking_handler
|
||||||
|
#pragma weak eth_isr = blocking_handler
|
||||||
|
#pragma weak eth_wkup_isr = blocking_handler
|
||||||
|
#pragma weak can2_tx_isr = blocking_handler
|
||||||
|
#pragma weak can2_rx0_isr = blocking_handler
|
||||||
|
#pragma weak can2_rx1_isr = blocking_handler
|
||||||
|
#pragma weak can2_sce_isr = blocking_handler
|
||||||
|
#pragma weak otg_fs_isr = blocking_handler
|
||||||
|
|
||||||
|
#elif defined STM32F2
|
||||||
|
#pragma weak nvic_wwdg_isr = blocking_handler
|
||||||
|
#pragma weak pvd_isr = blocking_handler
|
||||||
|
#pragma weak tamp_stamp_isr = blocking_handler
|
||||||
|
#pragma weak rtc_wkup_isr = blocking_handler
|
||||||
|
#pragma weak flash_isr = blocking_handler
|
||||||
|
#pragma weak rcc_isr = blocking_handler
|
||||||
|
#pragma weak exti0_isr = blocking_handler
|
||||||
|
#pragma weak exti1_isr = blocking_handler
|
||||||
|
#pragma weak exti2_isr = blocking_handler
|
||||||
|
#pragma weak exti3_isr = blocking_handler
|
||||||
|
#pragma weak exti4_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream0_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream1_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream2_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream3_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream4_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream5_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream6_isr = blocking_handler
|
||||||
|
#pragma weak adc_isr = blocking_handler
|
||||||
|
#pragma weak can1_tx_isr = blocking_handler
|
||||||
|
#pragma weak can1_rx0_isr = blocking_handler
|
||||||
|
#pragma weak can1_rx1_isr = blocking_handler
|
||||||
|
#pragma weak can1_sce_isr = blocking_handler
|
||||||
|
#pragma weak exti9_5_isr = blocking_handler
|
||||||
|
#pragma weak tim1_brk_tim9_isr = blocking_handler
|
||||||
|
#pragma weak tim1_up_tim10_isr = blocking_handler
|
||||||
|
#pragma weak tim1_trg_com_tim11_isr = blocking_handler
|
||||||
|
#pragma weak tim1_cc_isr = blocking_handler
|
||||||
|
#pragma weak tim2_isr = blocking_handler
|
||||||
|
#pragma weak tim3_isr = blocking_handler
|
||||||
|
#pragma weak tim4_isr = blocking_handler
|
||||||
|
#pragma weak i2c1_ev_isr = blocking_handler
|
||||||
|
#pragma weak i2c1_er_isr = blocking_handler
|
||||||
|
#pragma weak i2c2_ev_isr = blocking_handler
|
||||||
|
#pragma weak i2c2_er_isr = blocking_handler
|
||||||
|
#pragma weak spi1_isr = blocking_handler
|
||||||
|
#pragma weak spi2_isr = blocking_handler
|
||||||
|
#pragma weak usart1_isr = blocking_handler
|
||||||
|
#pragma weak usart2_isr = blocking_handler
|
||||||
|
#pragma weak usart3_isr = blocking_handler
|
||||||
|
#pragma weak exti15_10_isr = blocking_handler
|
||||||
|
#pragma weak rtc_alarm_isr = blocking_handler
|
||||||
|
#pragma weak usb_fs_wkup_isr = blocking_handler
|
||||||
|
#pragma weak tim8_brk_tim12_isr = blocking_handler
|
||||||
|
#pragma weak tim8_up_tim13_isr = blocking_handler
|
||||||
|
#pragma weak tim8_trg_com_tim14_isr = blocking_handler
|
||||||
|
#pragma weak tim8_cc_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream7_isr = blocking_handler
|
||||||
|
#pragma weak fsmc_isr = blocking_handler
|
||||||
|
#pragma weak sdio_isr = blocking_handler
|
||||||
|
#pragma weak tim5_isr = blocking_handler
|
||||||
|
#pragma weak spi3_isr = blocking_handler
|
||||||
|
#pragma weak uart4_isr = blocking_handler
|
||||||
|
#pragma weak uart5_isr = blocking_handler
|
||||||
|
#pragma weak tim6_dac_isr = blocking_handler
|
||||||
|
#pragma weak tim7_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream0_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream1_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream2_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream3_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream4_isr = blocking_handler
|
||||||
|
#pragma weak eth_isr = blocking_handler
|
||||||
|
#pragma weak eth_wkup_isr = blocking_handler
|
||||||
|
#pragma weak can2_tx_isr = blocking_handler
|
||||||
|
#pragma weak can2_rx0_isr = blocking_handler
|
||||||
|
#pragma weak can2_rx1_isr = blocking_handler
|
||||||
|
#pragma weak can2_sce_isr = blocking_handler
|
||||||
|
#pragma weak otg_fs_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream5_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream6_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream7_isr = blocking_handler
|
||||||
|
#pragma weak usart6_isr = blocking_handler
|
||||||
|
#pragma weak i2c3_ev_isr = blocking_handler
|
||||||
|
#pragma weak i2c3_er_isr = blocking_handler
|
||||||
|
#pragma weak otg_hs_ep1_out_isr = blocking_handler
|
||||||
|
#pragma weak otg_hs_ep1_in_isr = blocking_handler
|
||||||
|
#pragma weak otg_hs_wkup_isr = blocking_handler
|
||||||
|
#pragma weak otg_hs_isr = blocking_handler
|
||||||
|
#pragma weak dcmi_isr = blocking_handler
|
||||||
|
#pragma weak cryp_isr = blocking_handler
|
||||||
|
#pragma weak hash_rng_isr = blocking_handler
|
||||||
|
|
||||||
|
#elif defined STM32F3
|
||||||
|
#pragma weak nvic_wwdg_isr = blocking_handler
|
||||||
|
#pragma weak pvd_isr = blocking_handler
|
||||||
|
#pragma weak tamp_stamp_isr = blocking_handler
|
||||||
|
#pragma weak rtc_wkup_isr = blocking_handler
|
||||||
|
#pragma weak flash_isr = blocking_handler
|
||||||
|
#pragma weak rcc_isr = blocking_handler
|
||||||
|
#pragma weak exti0_isr = blocking_handler
|
||||||
|
#pragma weak exti1_isr = blocking_handler
|
||||||
|
#pragma weak exti2_tsc_isr = blocking_handler
|
||||||
|
#pragma weak exti3_isr = blocking_handler
|
||||||
|
#pragma weak exti4_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel1_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel2_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel3_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel4_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel5_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel6_isr = blocking_handler
|
||||||
|
#pragma weak dma1_channel7_isr = blocking_handler
|
||||||
|
#pragma weak adc1_2_isr = blocking_handler
|
||||||
|
#pragma weak usb_hp_can1_tx_isr = blocking_handler
|
||||||
|
#pragma weak usb_lp_can1_rx0_isr = blocking_handler
|
||||||
|
#pragma weak can1_rx1_isr = blocking_handler
|
||||||
|
#pragma weak can1_sce_isr = blocking_handler
|
||||||
|
#pragma weak exti9_5_isr = blocking_handler
|
||||||
|
#pragma weak tim1_brk_tim15_isr = blocking_handler
|
||||||
|
#pragma weak tim1_up_tim16_isr = blocking_handler
|
||||||
|
#pragma weak tim1_trg_com_tim17_isr = blocking_handler
|
||||||
|
#pragma weak tim1_cc_isr = blocking_handler
|
||||||
|
#pragma weak tim2_isr = blocking_handler
|
||||||
|
#pragma weak tim3_isr = blocking_handler
|
||||||
|
#pragma weak tim4_isr = blocking_handler
|
||||||
|
#pragma weak i2c1_ev_exti23_isr = blocking_handler
|
||||||
|
#pragma weak i2c1_er_isr = blocking_handler
|
||||||
|
#pragma weak i2c2_ev_exti24_isr = blocking_handler
|
||||||
|
#pragma weak i2c2_er_isr = blocking_handler
|
||||||
|
#pragma weak spi1_isr = blocking_handler
|
||||||
|
#pragma weak spi2_isr = blocking_handler
|
||||||
|
#pragma weak usart1_exti25_isr = blocking_handler
|
||||||
|
#pragma weak usart2_exti26_isr = blocking_handler
|
||||||
|
#pragma weak usart3_exti28_isr = blocking_handler
|
||||||
|
#pragma weak exti15_10_isr = blocking_handler
|
||||||
|
#pragma weak rtc_alarm_isr = blocking_handler
|
||||||
|
#pragma weak usb_wkup_a_isr = blocking_handler
|
||||||
|
#pragma weak tim8_brk_isr = blocking_handler
|
||||||
|
#pragma weak tim8_up_isr = blocking_handler
|
||||||
|
#pragma weak tim8_trg_com_isr = blocking_handler
|
||||||
|
#pragma weak tim8_cc_isr = blocking_handler
|
||||||
|
#pragma weak adc3_isr = blocking_handler
|
||||||
|
#pragma weak reserved_1_isr = blocking_handler
|
||||||
|
#pragma weak reserved_2_isr = blocking_handler
|
||||||
|
#pragma weak reserved_3_isr = blocking_handler
|
||||||
|
#pragma weak spi3_isr = blocking_handler
|
||||||
|
#pragma weak uart4_exti34_isr = blocking_handler
|
||||||
|
#pragma weak uart5_exti35_isr = blocking_handler
|
||||||
|
#pragma weak tim6_dac_isr = blocking_handler
|
||||||
|
#pragma weak tim7_isr = blocking_handler
|
||||||
|
#pragma weak dma2_channel1_isr = blocking_handler
|
||||||
|
#pragma weak dma2_channel2_isr = blocking_handler
|
||||||
|
#pragma weak dma2_channel3_isr = blocking_handler
|
||||||
|
#pragma weak dma2_channel4_isr = blocking_handler
|
||||||
|
#pragma weak dma2_channel5_isr = blocking_handler
|
||||||
|
#pragma weak eth_isr = blocking_handler
|
||||||
|
#pragma weak reserved_4_isr = blocking_handler
|
||||||
|
#pragma weak reserved_5_isr = blocking_handler
|
||||||
|
#pragma weak comp123_isr = blocking_handler
|
||||||
|
#pragma weak comp456_isr = blocking_handler
|
||||||
|
#pragma weak comp7_isr = blocking_handler
|
||||||
|
#pragma weak reserved_6_isr = blocking_handler
|
||||||
|
#pragma weak reserved_7_isr = blocking_handler
|
||||||
|
#pragma weak reserved_8_isr = blocking_handler
|
||||||
|
#pragma weak reserved_9_isr = blocking_handler
|
||||||
|
#pragma weak reserved_10_isr = blocking_handler
|
||||||
|
#pragma weak reserved_11_isr = blocking_handler
|
||||||
|
#pragma weak reserved_12_isr = blocking_handler
|
||||||
|
#pragma weak usb_hp_isr = blocking_handler
|
||||||
|
#pragma weak usb_lp_isr = blocking_handler
|
||||||
|
#pragma weak usb_wkup_isr = blocking_handler
|
||||||
|
#pragma weak reserved_13_isr = blocking_handler
|
||||||
|
#pragma weak reserved_14_isr = blocking_handler
|
||||||
|
#pragma weak reserved_15_isr = blocking_handler
|
||||||
|
#pragma weak reserved_16_isr = blocking_handler
|
||||||
|
|
||||||
|
#elif defined STM32F4
|
||||||
|
#pragma weak nvic_wwdg_isr = blocking_handler
|
||||||
|
#pragma weak pvd_isr = blocking_handler
|
||||||
|
#pragma weak tamp_stamp_isr = blocking_handler
|
||||||
|
#pragma weak rtc_wkup_isr = blocking_handler
|
||||||
|
#pragma weak flash_isr = blocking_handler
|
||||||
|
#pragma weak rcc_isr = blocking_handler
|
||||||
|
#pragma weak exti0_isr = blocking_handler
|
||||||
|
#pragma weak exti1_isr = blocking_handler
|
||||||
|
#pragma weak exti2_isr = blocking_handler
|
||||||
|
#pragma weak exti3_isr = blocking_handler
|
||||||
|
#pragma weak exti4_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream0_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream1_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream2_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream3_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream4_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream5_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream6_isr = blocking_handler
|
||||||
|
#pragma weak adc_isr = blocking_handler
|
||||||
|
#pragma weak can1_tx_isr = blocking_handler
|
||||||
|
#pragma weak can1_rx0_isr = blocking_handler
|
||||||
|
#pragma weak can1_rx1_isr = blocking_handler
|
||||||
|
#pragma weak can1_sce_isr = blocking_handler
|
||||||
|
#pragma weak exti9_5_isr = blocking_handler
|
||||||
|
#pragma weak tim1_brk_tim9_isr = blocking_handler
|
||||||
|
#pragma weak tim1_up_tim10_isr = blocking_handler
|
||||||
|
#pragma weak tim1_trg_com_tim11_isr = blocking_handler
|
||||||
|
#pragma weak tim1_cc_isr = blocking_handler
|
||||||
|
#pragma weak tim2_isr = blocking_handler
|
||||||
|
#pragma weak tim3_isr = blocking_handler
|
||||||
|
#pragma weak tim4_isr = blocking_handler
|
||||||
|
#pragma weak i2c1_ev_isr = blocking_handler
|
||||||
|
#pragma weak i2c1_er_isr = blocking_handler
|
||||||
|
#pragma weak i2c2_ev_isr = blocking_handler
|
||||||
|
#pragma weak i2c2_er_isr = blocking_handler
|
||||||
|
#pragma weak spi1_isr = blocking_handler
|
||||||
|
#pragma weak spi2_isr = blocking_handler
|
||||||
|
#pragma weak usart1_isr = blocking_handler
|
||||||
|
#pragma weak usart2_isr = blocking_handler
|
||||||
|
#pragma weak usart3_isr = blocking_handler
|
||||||
|
#pragma weak exti15_10_isr = blocking_handler
|
||||||
|
#pragma weak rtc_alarm_isr = blocking_handler
|
||||||
|
#pragma weak usb_fs_wkup_isr = blocking_handler
|
||||||
|
#pragma weak tim8_brk_tim12_isr = blocking_handler
|
||||||
|
#pragma weak tim8_up_tim13_isr = blocking_handler
|
||||||
|
#pragma weak tim8_trg_com_tim14_isr = blocking_handler
|
||||||
|
#pragma weak tim8_cc_isr = blocking_handler
|
||||||
|
#pragma weak dma1_stream7_isr = blocking_handler
|
||||||
|
#pragma weak fsmc_isr = blocking_handler
|
||||||
|
#pragma weak sdio_isr = blocking_handler
|
||||||
|
#pragma weak tim5_isr = blocking_handler
|
||||||
|
#pragma weak spi3_isr = blocking_handler
|
||||||
|
#pragma weak uart4_isr = blocking_handler
|
||||||
|
#pragma weak uart5_isr = blocking_handler
|
||||||
|
#pragma weak tim6_dac_isr = blocking_handler
|
||||||
|
#pragma weak tim7_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream0_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream1_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream2_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream3_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream4_isr = blocking_handler
|
||||||
|
#pragma weak eth_isr = blocking_handler
|
||||||
|
#pragma weak eth_wkup_isr = blocking_handler
|
||||||
|
#pragma weak can2_tx_isr = blocking_handler
|
||||||
|
#pragma weak can2_rx0_isr = blocking_handler
|
||||||
|
#pragma weak can2_rx1_isr = blocking_handler
|
||||||
|
#pragma weak can2_sce_isr = blocking_handler
|
||||||
|
#pragma weak otg_fs_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream5_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream6_isr = blocking_handler
|
||||||
|
#pragma weak dma2_stream7_isr = blocking_handler
|
||||||
|
#pragma weak usart6_isr = blocking_handler
|
||||||
|
#pragma weak i2c3_ev_isr = blocking_handler
|
||||||
|
#pragma weak i2c3_er_isr = blocking_handler
|
||||||
|
#pragma weak otg_hs_ep1_out_isr = blocking_handler
|
||||||
|
#pragma weak otg_hs_ep1_in_isr = blocking_handler
|
||||||
|
#pragma weak otg_hs_wkup_isr = blocking_handler
|
||||||
|
#pragma weak otg_hs_isr = blocking_handler
|
||||||
|
#pragma weak dcmi_isr = blocking_handler
|
||||||
|
#pragma weak cryp_isr = blocking_handler
|
||||||
|
#pragma weak hash_rng_isr = blocking_handler
|
||||||
|
#pragma weak fpu_isr = blocking_handler
|
||||||
|
#pragma weak uart7_isr = blocking_handler
|
||||||
|
#pragma weak uart8_isr = blocking_handler
|
||||||
|
#pragma weak spi4_isr = blocking_handler
|
||||||
|
#pragma weak spi5_isr = blocking_handler
|
||||||
|
#pragma weak spi6_isr = blocking_handler
|
||||||
|
#pragma weak sai1_isr = blocking_handler
|
||||||
|
#pragma weak lcd_tft_isr = blocking_handler
|
||||||
|
#pragma weak lcd_tft_err_isr = blocking_handler
|
||||||
|
#pragma weak dma2d_isr = blocking_handler
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void main(void);
|
||||||
|
void blocking_handler(void);
|
||||||
|
void null_handler(void);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int *initial_sp_value; /**< Initial stack pointer value. */
|
||||||
|
vector_table_entry_t reset;
|
||||||
|
vector_table_entry_t nmi;
|
||||||
|
vector_table_entry_t hard_fault;
|
||||||
|
vector_table_entry_t memory_manage_fault; /* not in CM0 */
|
||||||
|
vector_table_entry_t bus_fault; /* not in CM0 */
|
||||||
|
vector_table_entry_t usage_fault; /* not in CM0 */
|
||||||
|
vector_table_entry_t reserved_x001c[4];
|
||||||
|
vector_table_entry_t sv_call;
|
||||||
|
vector_table_entry_t debug_monitor; /* not in CM0 */
|
||||||
|
vector_table_entry_t reserved_x0034;
|
||||||
|
vector_table_entry_t pend_sv;
|
||||||
|
vector_table_entry_t systick;
|
||||||
|
vector_table_entry_t irq[NVIC_IRQ_COUNT];
|
||||||
|
} vector_table_t;
|
||||||
|
|
||||||
|
__attribute__ ((section(".vectors")))
|
||||||
|
vector_table_t vector_table = {
|
||||||
|
.initial_sp_value = &_stack,
|
||||||
|
.reset = reset_handler,
|
||||||
|
.nmi = nmi_handler,
|
||||||
|
.hard_fault = hard_fault_handler,
|
||||||
|
|
||||||
|
/* Those are defined only on CM3 or CM4 */
|
||||||
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
||||||
|
.memory_manage_fault = mem_manage_handler,
|
||||||
|
.bus_fault = bus_fault_handler,
|
||||||
|
.usage_fault = usage_fault_handler,
|
||||||
|
.debug_monitor = debug_monitor_handler,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
.sv_call = sv_call_handler,
|
||||||
|
.pend_sv = pend_sv_handler,
|
||||||
|
.systick = sys_tick_handler,
|
||||||
|
.irq = {
|
||||||
|
IRQ_HANDLERS
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void WEAK __attribute__ ((naked)) reset_handler(void)
|
||||||
|
{
|
||||||
|
volatile unsigned *src, *dest;
|
||||||
|
funcp_t *fp;
|
||||||
|
|
||||||
|
for (src = &_data_loadaddr, dest = &_data;
|
||||||
|
dest < &_edata;
|
||||||
|
src++, dest++) {
|
||||||
|
*dest = *src;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (dest < &_ebss) {
|
||||||
|
*dest++ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Constructors. */
|
||||||
|
for (fp = &__preinit_array_start; fp < &__preinit_array_end; fp++) {
|
||||||
|
(*fp)();
|
||||||
|
}
|
||||||
|
for (fp = &__init_array_start; fp < &__init_array_end; fp++) {
|
||||||
|
(*fp)();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call the application's entry point. */
|
||||||
|
main();
|
||||||
|
|
||||||
|
/* Destructors. */
|
||||||
|
for (fp = &__fini_array_start; fp < &__fini_array_end; fp++) {
|
||||||
|
(*fp)();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void blocking_handler(void)
|
||||||
|
{
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void null_handler(void)
|
||||||
|
{
|
||||||
|
/* Do nothing. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
FOR f3/f4:
|
||||||
|
static void pre_main(void)
|
||||||
|
{
|
||||||
|
// Enable access to Floating-Point coprocessor.
|
||||||
|
SCB_CPACR |= SCB_CPACR_FULL * (SCB_CPACR_CP10 | SCB_CPACR_CP11);
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
143
F1-nolib/led_blink/Makefile
Normal file
143
F1-nolib/led_blink/Makefile
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
BINARY = blink
|
||||||
|
BOOTPORT ?= /dev/ttyUSB0
|
||||||
|
BOOTSPEED ?= 115200
|
||||||
|
# MCU FAMILY
|
||||||
|
FAMILY ?= F1
|
||||||
|
# MCU code
|
||||||
|
MCU ?= F103xB
|
||||||
|
#density (stm32f10x.h, lines 70-84)
|
||||||
|
DENSITY ?= MD
|
||||||
|
DEFS = -DEBUG
|
||||||
|
# change this linking script depending on particular MCU model,
|
||||||
|
# for example, if you have STM32F103VBT6, you should write:
|
||||||
|
LDSCRIPT ?= ld/stm32f103xB.ld
|
||||||
|
|
||||||
|
INDEPENDENT_HEADERS=
|
||||||
|
|
||||||
|
FP_FLAGS ?= -msoft-float
|
||||||
|
ASM_FLAGS ?= -mthumb -mcpu=cortex-m3 -mfix-cortex-m3-ldrd
|
||||||
|
ARCH_FLAGS = $(ASM_FLAGS) $(FP_FLAGS)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Executables
|
||||||
|
PREFIX ?= arm-none-eabi
|
||||||
|
|
||||||
|
RM := rm -f
|
||||||
|
RMDIR := rmdir
|
||||||
|
CC := $(PREFIX)-gcc
|
||||||
|
LD := $(PREFIX)-gcc
|
||||||
|
AR := $(PREFIX)-ar
|
||||||
|
AS := $(PREFIX)-as
|
||||||
|
OBJCOPY := $(PREFIX)-objcopy
|
||||||
|
OBJDUMP := $(PREFIX)-objdump
|
||||||
|
GDB := $(PREFIX)-gdb
|
||||||
|
STFLASH := $(shell which st-flash)
|
||||||
|
STBOOT := $(shell which stm32flash)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Source files
|
||||||
|
OBJDIR = mk
|
||||||
|
LDSCRIPT ?= $(BINARY).ld
|
||||||
|
SRC := $(wildcard *.c)
|
||||||
|
OBJS := $(addprefix $(OBJDIR)/, $(SRC:%.c=%.o))
|
||||||
|
STARTUP = $(OBJDIR)/startup.o
|
||||||
|
OBJS += $(STARTUP)
|
||||||
|
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 -MD -D__thumb2__=1
|
||||||
|
CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
|
||||||
|
CFLAGS += -Wredundant-decls
|
||||||
|
# -Wmissing-prototypes -Wstrict-prototypes
|
||||||
|
CFLAGS += -fno-common -ffunction-sections -fdata-sections
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Linker flags
|
||||||
|
LDFLAGS += --static -nostartfiles
|
||||||
|
#--specs=nano.specs
|
||||||
|
LDFLAGS += -L$(LIB_DIR)
|
||||||
|
LDFLAGS += -T$(LDSCRIPT)
|
||||||
|
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
|
||||||
|
LDFLAGS += -Wl,--gc-sections
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Used libraries
|
||||||
|
LDLIBS += -Wl,--start-group -lc -lgcc -Wl,--end-group
|
||||||
|
LDLIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
||||||
|
|
||||||
|
DEFS += -DSTM32$(FAMILY) -DSTM32$(MCU) -DSTM32F10X_$(DENSITY)
|
||||||
|
|
||||||
|
#.SUFFIXES: .elf .bin .hex .srec .list .map .images
|
||||||
|
#.SECONDEXPANSION:
|
||||||
|
#.SECONDARY:
|
||||||
|
|
||||||
|
ELF := $(OBJDIR)/$(BINARY).elf
|
||||||
|
LIST := $(OBJDIR)/$(BINARY).list
|
||||||
|
BIN := $(BINARY).bin
|
||||||
|
HEX := $(BINARY).hex
|
||||||
|
|
||||||
|
all: bin list
|
||||||
|
|
||||||
|
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) $(INCLUDE) $(ARCH_FLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.c
|
||||||
|
@echo " CC $<"
|
||||||
|
$(CC) $(CFLAGS) $(DEFS) $(INCLUDE) $(ARCH_FLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
#$(OBJDIR)/%.d: %.c $(OBJDIR)
|
||||||
|
# $(CC) -MM -MG $< | sed -e 's,^\([^:]*\)\.o[ ]*:,$(@D)/\1.o $(@D)/\1.d:,' >$@
|
||||||
|
|
||||||
|
$(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) $(ARCH_FLAGS) $(OBJS) $(LDLIBS) -o $(ELF)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo " CLEAN"
|
||||||
|
$(RM) $(OBJS) $(DEPS) $(ELF) $(HEX) $(LIST) $(OBJDIR)/*.map
|
||||||
|
@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
|
||||||
3
F1-nolib/led_blink/README
Normal file
3
F1-nolib/led_blink/README
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Toggle LEDs (PB8/PB9) on STM32F103 development board depending on buttons PC0,PC1:
|
||||||
|
- no jumper == 'SOS' in Morze
|
||||||
|
- with jumper - blink with period of 4 seconds
|
||||||
BIN
F1-nolib/led_blink/blink.bin
Executable file
BIN
F1-nolib/led_blink/blink.bin
Executable file
Binary file not shown.
9
F1-nolib/led_blink/ld/devices.data
Normal file
9
F1-nolib/led_blink/ld/devices.data
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
stm32f103?4* stm32f1 ROM=16K RAM=6K
|
||||||
|
stm32f103?6* stm32f1 ROM=32K RAM=10K
|
||||||
|
stm32f103?8* stm32f1 ROM=64K RAM=20K
|
||||||
|
stm32f103?b* stm32f1 ROM=128K RAM=20K
|
||||||
|
stm32f103?c* stm32f1 ROM=256K RAM=48K
|
||||||
|
stm32f103?d* stm32f1 ROM=384K RAM=64K
|
||||||
|
stm32f103?e* stm32f1 ROM=512K RAM=64K
|
||||||
|
stm32f103?f* stm32f1 ROM=768K RAM=96K
|
||||||
|
stm32f103?g* stm32f1 ROM=1024K RAM=96K
|
||||||
31
F1-nolib/led_blink/ld/stm32f103x4.ld
Normal file
31
F1-nolib/led_blink/ld/stm32f103x4.ld
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Linker script for STM32F100x4, 16K flash, 4K RAM. */
|
||||||
|
|
||||||
|
/* Define memory regions. */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
rom (rx) : ORIGIN = 0x08000000, LENGTH = 16K
|
||||||
|
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 6K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Include the common ld script. */
|
||||||
|
INCLUDE stm32f01234.ld
|
||||||
|
|
||||||
31
F1-nolib/led_blink/ld/stm32f103x6.ld
Normal file
31
F1-nolib/led_blink/ld/stm32f103x6.ld
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Linker script for STM32F100x4, 16K flash, 4K RAM. */
|
||||||
|
|
||||||
|
/* Define memory regions. */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
rom (rx) : ORIGIN = 0x08000000, LENGTH = 32K
|
||||||
|
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 10K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Include the common ld script. */
|
||||||
|
INCLUDE stm32f01234.ld
|
||||||
|
|
||||||
31
F1-nolib/led_blink/ld/stm32f103x8.ld
Normal file
31
F1-nolib/led_blink/ld/stm32f103x8.ld
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Linker script for STM32F100x4, 16K flash, 4K RAM. */
|
||||||
|
|
||||||
|
/* Define memory regions. */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
rom (rx) : ORIGIN = 0x08000000, LENGTH = 64K
|
||||||
|
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Include the common ld script. */
|
||||||
|
INCLUDE stm32f01234.ld
|
||||||
|
|
||||||
31
F1-nolib/led_blink/ld/stm32f103xB.ld
Normal file
31
F1-nolib/led_blink/ld/stm32f103xB.ld
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Linker script for STM32F100x4, 16K flash, 4K RAM. */
|
||||||
|
|
||||||
|
/* Define memory regions. */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
|
||||||
|
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Include the common ld script. */
|
||||||
|
INCLUDE stm32f01234.ld
|
||||||
|
|
||||||
31
F1-nolib/led_blink/ld/stm32f103xC.ld
Normal file
31
F1-nolib/led_blink/ld/stm32f103xC.ld
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Linker script for STM32F100x4, 16K flash, 4K RAM. */
|
||||||
|
|
||||||
|
/* Define memory regions. */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
rom (rx) : ORIGIN = 0x08000000, LENGTH = 256K
|
||||||
|
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Include the common ld script. */
|
||||||
|
INCLUDE stm32f01234.ld
|
||||||
|
|
||||||
31
F1-nolib/led_blink/ld/stm32f103xD.ld
Normal file
31
F1-nolib/led_blink/ld/stm32f103xD.ld
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Linker script for STM32F100x4, 16K flash, 4K RAM. */
|
||||||
|
|
||||||
|
/* Define memory regions. */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
rom (rx) : ORIGIN = 0x08000000, LENGTH = 384K
|
||||||
|
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Include the common ld script. */
|
||||||
|
INCLUDE stm32f01234.ld
|
||||||
|
|
||||||
31
F1-nolib/led_blink/ld/stm32f103xE.ld
Normal file
31
F1-nolib/led_blink/ld/stm32f103xE.ld
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Linker script for STM32F100x4, 16K flash, 4K RAM. */
|
||||||
|
|
||||||
|
/* Define memory regions. */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
||||||
|
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Include the common ld script. */
|
||||||
|
INCLUDE stm32f01234.ld
|
||||||
|
|
||||||
31
F1-nolib/led_blink/ld/stm32f103xF.ld
Normal file
31
F1-nolib/led_blink/ld/stm32f103xF.ld
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Linker script for STM32F100x4, 16K flash, 4K RAM. */
|
||||||
|
|
||||||
|
/* Define memory regions. */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
rom (rx) : ORIGIN = 0x08000000, LENGTH = 768K
|
||||||
|
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 96K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Include the common ld script. */
|
||||||
|
INCLUDE stm32f01234.ld
|
||||||
|
|
||||||
31
F1-nolib/led_blink/ld/stm32f103xG.ld
Normal file
31
F1-nolib/led_blink/ld/stm32f103xG.ld
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Linker script for STM32F100x4, 16K flash, 4K RAM. */
|
||||||
|
|
||||||
|
/* Define memory regions. */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
|
||||||
|
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 96K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Include the common ld script. */
|
||||||
|
INCLUDE stm32f01234.ld
|
||||||
|
|
||||||
31
F1-nolib/led_blink/systick_blink.c
Normal file
31
F1-nolib/led_blink/systick_blink.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* systick_blink.c
|
||||||
|
*
|
||||||
|
* Copyright 2017 Edward V. Emelianoff <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stm32f1.h"
|
||||||
|
|
||||||
|
int main(void){
|
||||||
|
sysreset();
|
||||||
|
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
|
||||||
|
GPIOB->CRH = 0x00000066; // PB8/9 - 2MHz opendrain
|
||||||
|
GPIOB->ODR = 0;
|
||||||
|
while(1){}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
115
F1-nolib/led_blink/systick_blink.c_bkp
Normal file
115
F1-nolib/led_blink/systick_blink.c_bkp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* systick_blink.c
|
||||||
|
*
|
||||||
|
* Copyright 2017 Edward V. Emelianoff <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stm32f1.h"
|
||||||
|
|
||||||
|
static volatile uint8_t blink_ctr = 0;
|
||||||
|
|
||||||
|
/* Called when systick fires */
|
||||||
|
void sys_tick_handler(void){
|
||||||
|
++blink_ctr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up timer to fire every x milliseconds
|
||||||
|
*/
|
||||||
|
static void systick_setup(uint32_t xms){
|
||||||
|
static uint32_t curms = 0;
|
||||||
|
if(curms == xms) return;
|
||||||
|
// 6MHz - HCLK/8 (due to HPRE=1 HCLK=SYSCLK)
|
||||||
|
// this function also clears counter so it starts right away
|
||||||
|
SysTick_Config(6000 * xms);
|
||||||
|
curms = xms;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* set STM32 to clock by 48MHz from HSI oscillator */
|
||||||
|
//static void clock_setup(void){
|
||||||
|
//StartHSE(RCC_CR_CSSON | RCC_CR_HSEBYP);
|
||||||
|
//}
|
||||||
|
|
||||||
|
static void gpio_setup(void){
|
||||||
|
/* Enable clocks to the GPIO subsystems (A&B) */
|
||||||
|
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN | RCC_APB2ENR_IOPCEN;
|
||||||
|
/* Set leds (PB8/PB9) as opendrain output */
|
||||||
|
GPIOB->CRH = CRH(8, CNF_ODOUTPUT|MODE_SLOW) | CRH(9, CNF_ODOUTPUT|MODE_SLOW);
|
||||||
|
/* Set buttons (PC0/1) as inputs with weak pullups */
|
||||||
|
GPIOC->ODR = 3; // pullups for PC0/1
|
||||||
|
GPIOC->CRL = CRL(0, CNF_PUDINPUT|MODE_INPUT) | CRL(1, CNF_PUDINPUT|MODE_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const uint16_t L[] = {125,100,125,100,125,200, 350,100,350,100,350,200, 125,100,125,100,125, 1000};
|
||||||
|
|
||||||
|
int main(void){
|
||||||
|
sysreset();
|
||||||
|
// AFIO->MAPR = AFIO_MAPR_SWJ_CFG_DISABLE; // turn off jtag and swim
|
||||||
|
// StartHSE();
|
||||||
|
|
||||||
|
RCC->CFGR &= ~RCC_CFGR_SW; // Change System Clock to HSI
|
||||||
|
while ((RCC->CFGR & RCC_CFGR_SWS) != 0x00) {
|
||||||
|
__NOP();
|
||||||
|
};
|
||||||
|
RCC->CR &= ~RCC_CR_PLLON; // Disable Pll
|
||||||
|
while ((RCC->CR & RCC_CR_PLLON)) {
|
||||||
|
__NOP();
|
||||||
|
};
|
||||||
|
RCC->CFGR &= ~0x3C0000;
|
||||||
|
RCC->CFGR |= RCC_CFGR_PLLMULL4; // Set Pll Mul to 4
|
||||||
|
RCC->CFGR |= RCC_CFGR_USBPRE;
|
||||||
|
RCC->CFGR |= RCC_CFGR_PLLSRC;
|
||||||
|
RCC->CR |= RCC_CR_PLLON;
|
||||||
|
while (!(RCC->CR & RCC_CR_PLLON)) {
|
||||||
|
__NOP();
|
||||||
|
};
|
||||||
|
RCC->CFGR |= RCC_CFGR_SW_1; // Change System Clock to PLL
|
||||||
|
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_1) {
|
||||||
|
__NOP();
|
||||||
|
};
|
||||||
|
|
||||||
|
gpio_setup();
|
||||||
|
|
||||||
|
/* 500ms ticks => 1000ms period => 1Hz blinks */
|
||||||
|
systick_setup(100);
|
||||||
|
uint8_t oldctr = blink_ctr+1;
|
||||||
|
pin_clear(GPIOB, 1<<8);
|
||||||
|
pin_clear(GPIOB, 1<<9);
|
||||||
|
for(int i = 0; i < 1000000; ++i) nop();
|
||||||
|
/* Do nothing in main loop */
|
||||||
|
while (1){
|
||||||
|
if(pin_read(GPIOC, 1) && pin_read(GPIOC, 2)){ // no buttons present - morze @ LED1 (PB9)
|
||||||
|
if(oldctr != blink_ctr){
|
||||||
|
uint32_t T = blink_ctr % 18;
|
||||||
|
systick_setup(L[T]);
|
||||||
|
if(T & 1) pin_set(GPIOB, 1<<9);
|
||||||
|
else pin_clear(GPIOB, 1<<9);
|
||||||
|
oldctr = blink_ctr;
|
||||||
|
}
|
||||||
|
}else{ // button pressed: turn ON given LED
|
||||||
|
if(pin_read(GPIOC, 1)){ // PC0 pressed (button S2)
|
||||||
|
pin_clear(GPIOB, 1<<8);
|
||||||
|
}else pin_set(GPIOB, 1<<8);
|
||||||
|
if(pin_read(GPIOC, 2)){ // PC1 pressed (button S3)
|
||||||
|
pin_clear(GPIOB, 1<<9);
|
||||||
|
}else pin_set(GPIOB, 1<<8);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
30
F1-nolib/led_blink/systick_blink.c_notwork
Normal file
30
F1-nolib/led_blink/systick_blink.c_notwork
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* systick_blink.c
|
||||||
|
*
|
||||||
|
* Copyright 2017 Edward V. Emelianoff <eddy@sao.ru, edward.emelianoff@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stm32f1.h"
|
||||||
|
|
||||||
|
int main(void){
|
||||||
|
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
|
||||||
|
GPIOB->CRH = 0x00000066; // PB8/9 - 2MHz opendrain
|
||||||
|
GPIOB->ODR = 0;
|
||||||
|
while(1){}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user