├── platform ├── common.mk ├── stm32f10x │ ├── Makefile │ ├── platform.h │ ├── stm32f10x_conf.h │ └── stm32_p103.c └── stm32f429 │ ├── Makefile │ ├── platform.h │ ├── stm32_p103.c │ └── stm32f4xx_conf.h ├── app ├── build.mk ├── posixtestsuit │ ├── posixtest.h │ ├── pthread_create │ │ ├── posixtest.h │ │ └── 1-1.c │ └── 1-2.c └── lcd_test │ └── main.c ├── .gitignore ├── libraries ├── CMSIS │ ├── License.doc │ ├── CMSIS debug support.htm │ ├── Documentation │ │ └── CMSIS_Core.htm │ ├── CM4 │ │ ├── DeviceSupport │ │ │ └── ST │ │ │ │ └── stm32f429 │ │ │ │ ├── Include │ │ │ │ ├── stm32f4xx.h │ │ │ │ └── system_stm32f4xx.h │ │ │ │ └── startup │ │ │ │ └── TASKING │ │ │ │ └── cstart_thumb2.asm │ │ └── CoreSupport │ │ │ ├── arm_const_structs.h │ │ │ └── arm_common_tables.h │ └── CM3 │ │ └── DeviceSupport │ │ └── ST │ │ └── stm32f10x │ │ └── Include │ │ └── system_stm32f10x.h ├── stm32f10x_StdPeriph_Driver │ ├── src │ │ ├── stm32f10x_i2c.c │ │ ├── stm32f10x_flash.c │ │ ├── stm32f10x_usart.c │ │ ├── stm32f10x_crc.c │ │ └── stm32f10x_dbgmcu.c │ └── inc │ │ ├── stm32f10x_crc.h │ │ ├── stm32f10x_wwdg.h │ │ ├── stm32f10x_dbgmcu.h │ │ ├── stm32f10x_rtc.h │ │ ├── stm32f10x_iwdg.h │ │ └── stm32f10x_pwr.h └── stm32f429_StdPeriph_Driver │ ├── Release_Notes.html │ ├── inc │ ├── stm32f4xx_crc.h │ ├── stm32f4xx_wwdg.h │ ├── stm32f4xx_rng.h │ ├── stm32f4xx_dbgmcu.h │ ├── stm32f4xx_iwdg.h │ └── stm32f429i_discovery_sdram.h │ ├── Common │ ├── fonts.h │ ├── lcd_log_conf_template.h │ └── lcd_log.h │ └── src │ └── stm32f4xx_crc.c ├── include ├── romfs.h ├── romdev.h ├── malloc.h ├── utils.h ├── memory-pool.h ├── fs.h ├── string.h ├── rtenv.h ├── syscall.h ├── path.h ├── kernel.h ├── mqueue.h ├── stm32_p103.h ├── fifo.h ├── trace.h ├── host.h ├── list.h ├── event-monitor.h ├── regfile.h ├── task.h ├── kconfig.h ├── pipe.h ├── block.h ├── file.h ├── pthread.h ├── RTOSConfig.h ├── signal.h ├── pthreadtypes.h └── erron.h ├── .travis_qemu.sh ├── .travis_libnewlib-arm.sh ├── AUTHORS ├── NEWS ├── src ├── memory-pool.c ├── pipe.c ├── list.c ├── string.c ├── memcpy.s ├── signal.c ├── syscall.s ├── host.c ├── event-monitor.c ├── romdev.c ├── context_switch.s ├── malloc.c ├── task.c ├── fifo.c ├── mqueue.c └── trace.c ├── mk ├── romfs.mk ├── rules.mk └── qemu.mk ├── .clang-format ├── tool ├── emulate_remote.sh ├── emulate.sh ├── gdbscript └── mkromfs.c ├── main.ld ├── .travis_gcc-arm.sh ├── .travis.yml ├── LICENSE └── Makefile /platform/common.mk: -------------------------------------------------------------------------------- 1 | include $(TOP)/Makefile 2 | -------------------------------------------------------------------------------- /app/build.mk: -------------------------------------------------------------------------------- 1 | 2 | 3 | #APP_DIR += app/posixtestsuit 4 | APP_DIR = 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | main.bin 2 | main.elf 3 | main.list 4 | main.map 5 | /build 6 | /data 7 | /build_stmf4 8 | -------------------------------------------------------------------------------- /platform/stm32f10x/Makefile: -------------------------------------------------------------------------------- 1 | ARCH := CM3 2 | PLAT := stm32f10x 3 | include $(TOP)/platform/common.mk 4 | -------------------------------------------------------------------------------- /platform/stm32f429/Makefile: -------------------------------------------------------------------------------- 1 | ARCH := CM4 2 | PLAT := stm32f429 3 | include $(TOP)/platform/common.mk 4 | -------------------------------------------------------------------------------- /libraries/CMSIS/License.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lecopzer/rtenv-plus/HEAD/libraries/CMSIS/License.doc -------------------------------------------------------------------------------- /libraries/CMSIS/CMSIS debug support.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lecopzer/rtenv-plus/HEAD/libraries/CMSIS/CMSIS debug support.htm -------------------------------------------------------------------------------- /platform/stm32f10x/platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __PLATFORM_H__ 2 | #define __PLATFORM_H__ 3 | 4 | #include "stm32f10x.h" 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /platform/stm32f429/platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __PLATFORM_H__ 2 | #define __PLATFORM_H__ 3 | 4 | #include "stm32f4xx.h" 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /include/romfs.h: -------------------------------------------------------------------------------- 1 | #ifndef ROMFS_H 2 | #define ROMFS_H 3 | 4 | #define ROMFS_TYPE "romfs" 5 | 6 | void romfs_server(); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libraries/CMSIS/Documentation/CMSIS_Core.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lecopzer/rtenv-plus/HEAD/libraries/CMSIS/Documentation/CMSIS_Core.htm -------------------------------------------------------------------------------- /include/romdev.h: -------------------------------------------------------------------------------- 1 | #ifndef ROMDEV_H 2 | #define ROMDEV_H 3 | 4 | #define ROMDEV_PATH "/dev/rom0" 5 | 6 | void romdev_driver(); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /include/malloc.h: -------------------------------------------------------------------------------- 1 | #ifndef __MALLOC_H_ 2 | #define __MALLOC_H_ 3 | 4 | void *malloc(unsigned int nbytes); 5 | void free(void *ap); 6 | 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /libraries/stm32f10x_StdPeriph_Driver/src/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lecopzer/rtenv-plus/HEAD/libraries/stm32f10x_StdPeriph_Driver/src/stm32f10x_i2c.c -------------------------------------------------------------------------------- /libraries/stm32f429_StdPeriph_Driver/Release_Notes.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lecopzer/rtenv-plus/HEAD/libraries/stm32f429_StdPeriph_Driver/Release_Notes.html -------------------------------------------------------------------------------- /libraries/stm32f10x_StdPeriph_Driver/src/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lecopzer/rtenv-plus/HEAD/libraries/stm32f10x_StdPeriph_Driver/src/stm32f10x_flash.c -------------------------------------------------------------------------------- /libraries/stm32f10x_StdPeriph_Driver/src/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lecopzer/rtenv-plus/HEAD/libraries/stm32f10x_StdPeriph_Driver/src/stm32f10x_usart.c -------------------------------------------------------------------------------- /libraries/CMSIS/CM4/DeviceSupport/ST/stm32f429/Include/stm32f4xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lecopzer/rtenv-plus/HEAD/libraries/CMSIS/CM4/DeviceSupport/ST/stm32f429/Include/stm32f4xx.h -------------------------------------------------------------------------------- /include/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_H 2 | #define UTILS_H 3 | 4 | #include 5 | 6 | #define container_of(ptr, type, member) \ 7 | ((type *)(((void *)ptr) - offsetof(type, member))) 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /.travis_qemu.sh: -------------------------------------------------------------------------------- 1 | 2 | wget http://wiki.qemu-project.org/download/qemu-2.4.0.tar.bz2 3 | 4 | 5 | tar -xjf qemu-2.4.0.tar.bz2 6 | cd ./qemu-2.4.0/ 7 | ./configure --target-list=arm-softmmu,arm-linux-user 8 | 9 | make -j2 10 | sudo make install 11 | 12 | cd .. 13 | -------------------------------------------------------------------------------- /.travis_libnewlib-arm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | wget https://launchpad.net/ubuntu/+archive/primary/+files/newlib_2.1.0.orig.tar.gz 4 | 5 | 6 | tar -xzf newlib_2.1.0.orig.tar.gz 7 | cd ./newlib-2.1.0/ 8 | 9 | ./configure 10 | sudo make 11 | sudo make install 12 | 13 | cd .. 14 | -------------------------------------------------------------------------------- /include/memory-pool.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORY_POOL_H 2 | #define MEMORY_POOL_H 3 | 4 | #include 5 | 6 | struct memory_pool { 7 | int offset; 8 | size_t size; 9 | char *memory; 10 | }; 11 | 12 | void memory_pool_init(struct memory_pool *pool, size_t size, char *memory); 13 | void *memory_pool_alloc(struct memory_pool *pool, size_t size); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/fs.h: -------------------------------------------------------------------------------- 1 | #ifndef FS_H 2 | #define FS_H 3 | 4 | #include "kconfig.h" 5 | 6 | #define FS_CMD_OPEN 1 7 | #define FS_CMD_READ 2 8 | #define FS_CMD_WRITE 3 9 | #define FS_CMD_SEEK 4 10 | 11 | struct fs_request { 12 | int cmd; 13 | int from; 14 | int device; 15 | int target; 16 | char path[PATH_MAX]; 17 | int size; 18 | int pos; 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | This software is written by: 2 | Zhe-An Lin 3 | Jim Huang 4 | Bo-cheng Jan 5 | lecopzer 6 | 7 | External source files from CMSIS/ST listed in directory "libraries" were 8 | copyrighted by: 9 | STMicroelectronics (libraries/stm32f*StdPeriph_Driver) 10 | ARM Ltd (libraries/CMSIS) 11 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | What's New in rtenv GIT 2 | ------------------------------------------------------------------- 3 | * ROM file system offers a read-only file system during compilation 4 | * Various build system improvements 5 | * Fix memcpy error 6 | * Support of block devices 7 | * Fix of memory configuration 8 | * Introduce event monitor technique to handle interrupts 9 | * Efficient I/O encapsulation 10 | -------------------------------------------------------------------------------- /include/string.h: -------------------------------------------------------------------------------- 1 | #ifndef STRING_H 2 | #define STRING_H 3 | 4 | #include 5 | 6 | void *memcpy(void *dest, const void *src, size_t n); 7 | int strcmp(const char *a, const char *b) __attribute__ ((naked)); 8 | size_t strlen(const char *s) __attribute__ ((naked)); 9 | char *strcpy(char *dest, const char *src); 10 | int strncmp(const char *s1, const char *s2, size_t n); 11 | void puts(char *s); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/memory-pool.c: -------------------------------------------------------------------------------- 1 | #include "memory-pool.h" 2 | 3 | 4 | 5 | void memory_pool_init(struct memory_pool *pool, size_t size, char *memory) { 6 | pool->offset = 0; 7 | pool->size = size; 8 | pool->memory = memory; 9 | } 10 | 11 | void *memory_pool_alloc(struct memory_pool *pool, size_t size) { 12 | if (pool->offset + size <= pool->size) { 13 | char *alloc = pool->memory + pool->offset; 14 | pool->offset += size; 15 | return alloc; 16 | } 17 | 18 | return NULL; 19 | } 20 | -------------------------------------------------------------------------------- /include/rtenv.h: -------------------------------------------------------------------------------- 1 | #ifndef RTENV_H 2 | #define RTENV_H 3 | 4 | #include 5 | #include 6 | 7 | #include "task.h" 8 | #include "pthread.h" 9 | #include "malloc.h" 10 | 11 | #include "kconfig.h" 12 | #include "kernel.h" 13 | 14 | #include "platform.h" 15 | #include "RTOSConfig.h" 16 | 17 | #include "string.h" 18 | #include "file.h" 19 | 20 | #include "mqueue.h" 21 | #include "syscall.h" 22 | #include "signal.h" 23 | 24 | #include "path.h" 25 | #include "fifo.h" 26 | 27 | 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/syscall.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void *activate(void *stack); 4 | 5 | int fork(); 6 | int getpid(); 7 | 8 | int write(int fd, const void *buf, size_t count); 9 | int read(int fd, void *buf, size_t count); 10 | 11 | void interrupt_wait(int intr); 12 | 13 | int getpriority(int who); 14 | int setpriority(int who, int value); 15 | 16 | int mknod(int fd, int mode, int dev); 17 | 18 | void sleep(unsigned int); 19 | 20 | void lseek(int fd, int offset, int whence); 21 | 22 | int mutex_lock(void*); 23 | int mutex_unlock(void*); 24 | -------------------------------------------------------------------------------- /app/posixtestsuit/posixtest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 | * Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com 4 | * This file is licensed under the GPL license. For the full content 5 | * of this license, see the COPYING file at the top level of this 6 | * source tree. 7 | */ 8 | 9 | /* 10 | * return codes 11 | */ 12 | #define PTS_PASS 0 13 | #define PTS_FAIL 1 14 | #define PTS_UNRESOLVED 2 15 | #define PTS_UNSUPPORTED 4 16 | #define PTS_UNTESTED 5 17 | 18 | #define perror printf 19 | #define printf puts 20 | 21 | 22 | -------------------------------------------------------------------------------- /include/path.h: -------------------------------------------------------------------------------- 1 | #ifndef PATH_H 2 | #define PATH_H 3 | 4 | #define PATH_SERVER_NAME "/sys/pathserver" 5 | 6 | #define PATH_CMD_MKFILE 1 7 | #define PATH_CMD_OPEN 2 8 | #define PATH_CMD_REGISTER_PATH 3 9 | #define PATH_CMD_REGISTER_FS 4 10 | #define PATH_CMD_MOUNT 5 11 | 12 | #define path_write_data(dst, src, len, pos) \ 13 | { \ 14 | memcpy(dst + pos, src, len); \ 15 | pos += len; \ 16 | } 17 | 18 | void pathserver(); 19 | int path_register(const char *pathname); 20 | int path_register_fs(const char *type); 21 | int mount(const char *src, const char *dst, const char *type, int flags); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef KERNEL_H 2 | #define KERNEL_H 3 | 4 | #include "task.h" 5 | #include "file.h" 6 | #include "event-monitor.h" 7 | #include 8 | 9 | #define INTR_EVENT(intr) (FILE_LIMIT + (intr) + 15) /* see INTR_LIMIT */ 10 | #define INTR_EVENT_REVERSE(event) ((event) - FILE_LIMIT - 15) 11 | #define TIME_EVENT (FILE_LIMIT + INTR_LIMIT) 12 | #define TASK_EVENT(pid) (TIME_EVENT + pid) 13 | #define MUTEX_EVENT(count) (TASK_EVENT(TASK_LIMIT) + count) 14 | #define _disable_irq() __asm__ __volatile__ ( "cpsid i" ); 15 | #define _enable_irq() __asm__ __volatile__ ( "cpsie i" ); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /app/posixtestsuit/pthread_create/posixtest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 | * Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com 4 | * This file is licensed under the GPL license. For the full content 5 | * of this license, see the COPYING file at the top level of this 6 | * source tree. 7 | */ 8 | 9 | /* 10 | * return codes 11 | */ 12 | #define PTS_PASS 0 13 | #define PTS_FAIL 1 14 | #define PTS_UNRESOLVED 2 15 | #define PTS_UNSUPPORTED 4 16 | #define PTS_UNTESTED 5 17 | 18 | #define perror printf 19 | #define printf puts 20 | 21 | 22 | -------------------------------------------------------------------------------- /mk/romfs.mk: -------------------------------------------------------------------------------- 1 | ROMDIR = $(DATDIR)/rom0 2 | DAT += $(OUTDIR)/$(DATDIR)/rom0.o 3 | 4 | $(OUTDIR)/$(ROMDIR).o: $(OUTDIR)/$(ROMDIR).bin 5 | @mkdir -p $(dir $@) 6 | @echo " OBJCOPY "$@ 7 | @$(CROSS_COMPILE)objcopy -I binary -O elf32-littlearm -B arm \ 8 | --prefix-sections '.rom' $< $@ 9 | 10 | $(OUTDIR)/$(ROMDIR).bin: $(ROMDIR) $(OUTDIR)/$(TOOLDIR)/mkromfs 11 | @mkdir -p $(dir $@) 12 | @echo " MKROMFS "$@ 13 | @$(OUTDIR)/$(TOOLDIR)/mkromfs -d $< -o $@ 14 | 15 | $(ROMDIR): 16 | @mkdir -p $@ 17 | 18 | $(OUTDIR)/%/mkromfs: %/mkromfs.c 19 | @mkdir -p $(dir $@) 20 | @echo " CC "$@ 21 | @gcc -Wall -o $@ $^ 22 | -------------------------------------------------------------------------------- /src/pipe.c: -------------------------------------------------------------------------------- 1 | #include "pipe.h" 2 | 3 | 4 | 5 | int pipe_read_release(struct event_monitor *monitor, int event, 6 | struct task_control_block *task, void *data) { 7 | struct file *file = data; 8 | struct file_request *request = (void *) task->stack->r0; 9 | 10 | return file_read(file, request, monitor); 11 | } 12 | 13 | int pipe_write_release(struct event_monitor *monitor, int event, 14 | struct task_control_block *task, void *data) { 15 | struct file *file = data; 16 | struct file_request *request = (void *) task->stack->r0; 17 | 18 | return file_write(file, request, monitor); 19 | } 20 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | Language: Cpp 3 | SpaceAfterCStyleCast: true 4 | SpaceBeforeParens: ControlStatements 5 | MaxEmptyLinesToKeep: 3 6 | AllowShortIfStatementsOnASingleLine: false 7 | AllowShortCaseLabelsOnASingleLine: false 8 | AllowShortLoopsOnASingleLine: false 9 | DerivePointerAlignment: false 10 | PointerAlignment: Right 11 | TabWidth: 4 12 | UseTab: Never 13 | IndentWidth: 4 14 | IndentCaseLabels: true 15 | SortIncludes: false 16 | BreakBeforeBraces: Custom 17 | BraceWrapping: 18 | BeforeElse: true 19 | AfterClass: false 20 | AfterControlStatement: false 21 | AfterEnum: false 22 | AfterFunction: false 23 | AfterStruct: false 24 | AccessModifierOffset: -4 25 | -------------------------------------------------------------------------------- /tool/emulate_remote.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | QEMU_STM32=../qemu_stm32/arm-softmmu/qemu-system-arm 4 | 5 | CUR=`dirname $0` 6 | CMDS=`sed -n -e 's/\(^[^#].*\)/\1/p' test.script` 7 | 8 | emulate () { 9 | $QEMU_STM32 \ 10 | -gdb tcp::3333 -S \ 11 | -M stm32-p103 \ 12 | -kernel $1 \ 13 | -vnc :1 <&0 & pid=$! 14 | } 15 | 16 | stm32_qemu () { 17 | emulate $1 <<< " 18 | $CMDS 19 | " 20 | echo "Modeling STM32 in QEMU..." 21 | (sleep $2; kill $pid; sleep 1; kill -KILL $pid)& timer=$! 22 | if ! wait $pid; then 23 | kill $timer 2>/dev/null 24 | echo 25 | echo "Modeling failed to execute in $2 seconds, giving up." 26 | exit -1 27 | fi 28 | kill $timer 29 | } 30 | 31 | stm32_qemu $1 6 32 | -------------------------------------------------------------------------------- /tool/emulate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | QEMU_STM32=../qemu_stm32/arm-softmmu/qemu-system-arm 4 | 5 | CUR=`dirname $0` 6 | CMDS=`sed -n -e 's/\(^[^#].*\)/\1/p' test.script` 7 | 8 | emulate () { 9 | $QEMU_STM32 \ 10 | -gdb tcp::3333 -S \ 11 | -M stm32-p103 \ 12 | -kernel $1 \ 13 | -monitor tcp:localhost:4444,server,nowait <&0 & pid=$! 14 | } 15 | 16 | stm32_qemu () { 17 | emulate $1 <<< " 18 | $CMDS 19 | " 20 | echo "Modeling STM32 in QEMU..." 21 | (sleep $2; kill $pid; sleep 1; kill -KILL $pid)& timer=$! 22 | if ! wait $pid; then 23 | kill $timer 2>/dev/null 24 | echo 25 | echo "Modeling failed to execute in $2 seconds, giving up." 26 | exit -1 27 | fi 28 | kill $timer 29 | } 30 | 31 | stm32_qemu $1 6 32 | -------------------------------------------------------------------------------- /include/mqueue.h: -------------------------------------------------------------------------------- 1 | #ifndef MQUEUE_H 2 | #define MQUEUE_H 3 | 4 | #include "file.h" 5 | #include "memory-pool.h" 6 | 7 | int mq_init(int fd, int driver_pid, struct file *files[], 8 | struct memory_pool *memory_pool, struct event_monitor *monitor); 9 | int mq_open(const char *name, int oflag); 10 | int mq_readable (struct file *file, struct file_request *request, 11 | struct event_monitor *monitor); 12 | int mq_writable (struct file *file, struct file_request *request, 13 | struct event_monitor *monitor); 14 | int mq_read (struct file *file, struct file_request *request, 15 | struct event_monitor *monitor); 16 | int mq_write (struct file *file, struct file_request *request, 17 | struct event_monitor *monitor); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/stm32_p103.h: -------------------------------------------------------------------------------- 1 | #ifndef __STM32_P103_H 2 | #define __STM32_P103_H 3 | 4 | /* This library contains routines for interfacing with the STM32 P103 board. */ 5 | 6 | /* Initialize the LED (the board only has one). */ 7 | void init_led(void); 8 | 9 | /* Initialize the button (the board only has one). */ 10 | void init_button(void); 11 | 12 | /* Configures the RS232 serial port using the following settings: 13 | * 9600 Baud 14 | * 8 bits + 1 stop bit 15 | * No parity bit 16 | * No hardware flow control 17 | * Note that the USART2 is not enabled in this routine. It is left disabled in 18 | * case any additional configuration is needed. 19 | */ 20 | void init_rs232(void); 21 | 22 | void enable_rs232_interrupts(void); 23 | 24 | void enable_rs232(void); 25 | 26 | #endif /* __STM32_P103_H */ 27 | -------------------------------------------------------------------------------- /include/fifo.h: -------------------------------------------------------------------------------- 1 | #ifndef FIFO_H 2 | #define FIFO_H 3 | 4 | #include "file.h" 5 | #include "memory-pool.h" 6 | 7 | int mkfifo(const char *pathname, int mode); 8 | int fifo_init(int fd, int driver_pid, struct file *files[], 9 | struct memory_pool *memory_pool, struct event_monitor *monitor); 10 | int fifo_readable (struct file *file, struct file_request *request, 11 | struct event_monitor *monitor); 12 | int fifo_writable (struct file *file, struct file_request *request, 13 | struct event_monitor *monitor); 14 | int fifo_read (struct file *file, struct file_request *request, 15 | struct event_monitor *monitor); 16 | int fifo_write (struct file *file, struct file_request *request, 17 | struct event_monitor *monitor); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/trace.h: -------------------------------------------------------------------------------- 1 | #ifndef TRACE_H 2 | #define TRACE_H 3 | 4 | /* open for semihosting */ 5 | /* #define TRACE */ 6 | int get_interrupt_priority(int interrupt); 7 | 8 | int snprintf(char *buf, size_t size, const char *format, ...); 9 | 10 | unsigned int get_current(); 11 | 12 | void trace_task_create(void *task, const char *task_name, unsigned int priority); 13 | void trace_task_switch(void *prev_task, unsigned int prev_tick, void *curr_task); 14 | 15 | void trace_create_mutex(void *mutex); 16 | 17 | void trace_queue_create(void *queue, int queue_type, unsigned int queue_size); 18 | void trace_queue_send(void *task, void *queue); 19 | void trace_queue_recv(void *task, void *queue); 20 | void trace_queue_block(void *task, void *queue); 21 | 22 | void trace_interrupt_in(); 23 | void trace_interrupt_in(); 24 | #endif 25 | -------------------------------------------------------------------------------- /main.ld: -------------------------------------------------------------------------------- 1 | ENTRY(__rtenv_start) 2 | MEMORY 3 | { 4 | FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K 5 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 60K 6 | } 7 | 8 | SECTIONS 9 | { 10 | .text : 11 | { 12 | KEEP(*(.isr_vector)) 13 | *(.text) 14 | *(.text.*) 15 | *(.rodata) 16 | *(.rodata*) 17 | _sromdev = .; 18 | *(.rom.*) 19 | _eromdev = .; 20 | _sidata = .; 21 | } >FLASH 22 | 23 | /* Initialized data will initially be loaded in FLASH at the end of the .text section. */ 24 | .data : AT (_sidata) 25 | { 26 | _sdata = .; 27 | *(.data) /* Initialized data */ 28 | *(.data*) 29 | _edata = .; 30 | } >RAM 31 | 32 | .bss : { 33 | _sbss = .; 34 | *(.bss) /* Zero-filled run time allocate data memory */ 35 | _ebss = .; 36 | } >RAM 37 | 38 | _estack = ORIGIN(RAM) + LENGTH(RAM); 39 | } 40 | -------------------------------------------------------------------------------- /include/host.h: -------------------------------------------------------------------------------- 1 | #ifndef HOST_H 2 | #define HOST_H 3 | #include 4 | #include 5 | 6 | 7 | /* 8 | *Reference: http://albert-oma.blogspot.tw/2012/04/semihosting.html 9 | */ 10 | enum HOST_SYSCALL{ 11 | SYS_OPEN=0x01, 12 | SYS_CLOSE, 13 | SYS_WRITEC, 14 | SYS_WRITE0, 15 | SYS_WRITE, 16 | SYS_READ, 17 | SYS_READC, 18 | SYS_ISERROR, 19 | SYS_ISTTY, 20 | SYS_SEEK, 21 | SYS_FLEN=0xC, 22 | SYS_TMPNAM, 23 | SYS_REMOVE, 24 | SYS_RENAME, 25 | SYS_CLOCK, 26 | SYS_TIME, 27 | SYS_SYSTEM, 28 | SYS_ERRNO, 29 | SYS_GET_CMDLINE=0x15, 30 | SYS_HEAPINFO, 31 | SYS_ELAPSED=0x30, 32 | SYS_TICKFREQ 33 | }; 34 | 35 | int host_call(enum HOST_SYSCALL, void *argv) __attribute__((naked)); 36 | 37 | int host_system(va_list v1); 38 | int host_open(va_list v1); 39 | int host_close(va_list v1); 40 | int host_write(va_list v1); 41 | 42 | int host_action(enum HOST_SYSCALL action, ...); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /tool/gdbscript: -------------------------------------------------------------------------------- 1 | shell rm -f gdb.txt 2 | file build/main.elf 3 | target ext :3333 4 | set debug timestamp on 5 | set logging on 6 | layout reg 7 | focus cmd 8 | 9 | #dprintf src/task.c:280,"current_task = %d, r7 = %d\n",current_task,current_tcb->stack->r7 10 | #watch current_tcb->stack->r7 11 | #b SysTick_Handler 12 | 13 | #b src/task.c:174 14 | #commands 15 | #printf "current_tcb->stack->r0 is %d\n",current_tcb->stack->r0 16 | #c 17 | #end 18 | 19 | #b src/kernel.c:315 20 | #commands 21 | #printf "ch is %c\n",put_ch[0] 22 | #end 23 | 24 | #b src/path.c:45 25 | #b file_read 26 | #b src/kernel.c:198 27 | #b src/kernel.c:112 28 | #b USART2_IRQHandler 29 | #b check_keyword 30 | 31 | #b src/kernel.c:145 32 | #commands 33 | #printf "c is = %c\n",c 34 | #end 35 | b SVC_Handler 36 | b context_switch 37 | b syscall_handler 38 | commands 39 | printf "current_tcb->stack->r7 is %d\n",current_tcb->stack->r7 40 | end 41 | 42 | c 43 | -------------------------------------------------------------------------------- /include/list.h: -------------------------------------------------------------------------------- 1 | #ifndef LIST_H 2 | #define LIST_H 3 | 4 | #include "utils.h" 5 | 6 | struct list { 7 | struct list *prev; 8 | struct list *next; 9 | }; 10 | 11 | #define list_entry(list, type, member) \ 12 | (container_of((list), type, member)) 13 | 14 | /* If no item is removed */ 15 | #define list_for_each(curr, list) \ 16 | for ((curr) = (list)->next; (curr) != (list); (curr) = (curr)->next) 17 | 18 | /* If some items may be removed */ 19 | #define list_for_each_safe(curr, next, list) \ 20 | for ((curr) = (list)->next, (next) = (curr)->next; \ 21 | (curr) != (list); (curr) = (next), (next) = (curr)->next) 22 | 23 | void list_init(struct list *list); 24 | int list_empty(struct list *list); 25 | void list_remove(struct list *list); 26 | void list_unshift(struct list *list, struct list *new); 27 | void list_push(struct list *list, struct list* new); 28 | struct list* list_shift(struct list* list); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /.travis_gcc-arm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | wget https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q2-update/+download/gcc-arm-none-eabi-4_9-2015q2-20150609-linux.tar.bz2 4 | 5 | tar -xjf gcc-arm-none-eabi-4_9-2015q2-20150609-linux.tar.bz2 6 | cd ./gcc-arm-none-eabi-4_9-2015q2/src 7 | find -name ’*.tar.*’ | xargs -I% tar -xf % 8 | 9 | cd ../ 10 | 11 | #Start building the toolchain. 12 | #Can specify "--skip_steps=mingw32" option to skip building windows host 13 | #toolchain, and if specify that option when building prerequisites, 14 | #you have to specify it when building toolchain too. 15 | # 16 | #Without option --build_tools, the tools in current PATH will be used. 17 | #You can download and deploy the provided prebuilt one, use it like 18 | #./build-prerequisites.sh --build_tools=/home/build/prebuilt-native-tools 19 | # or ./build-toolchain.sh --build_tools=/home/build/prebuilt-native-tools 20 | ./build-prerequisites.sh 21 | ./build-toolchain.sh 22 | 23 | cd .. 24 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: gcc 3 | 4 | env: 5 | - QEMU_STM32=qemu_stm32/arm-softmmu/qemu-system-arm 6 | 7 | before_install: 8 | - sudo apt-get install build-essential git zlib1g-dev libsdl1.2-dev libglib2.0-dev "automake*" "autoconf*" libtool libpixman-1-dev 9 | - sudo apt-get update -qq 10 | - sudo add-apt-repository --yes ppa:terry.guo/gcc-arm-embedded 11 | - sudo apt-get install lib32gcc1 lib32ncurses5 xorg-dev libsdl1.2debian:i386 12 | - sudo apt-get update -qq 13 | - sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf qemu-user gcc-arm-none-eabi 14 | - sudo apt-get update -qq 15 | 16 | script: 17 | - ./.travis_libnewlib-arm.sh 18 | - ./.travis_qemu.sh 19 | 20 | - git clone git://github.com/beckus/qemu_stm32.git || git clone https://github.com/beckus/qemu_stm32.git 21 | - cd qemu_stm32 22 | - git submodule update --init dtc || sudo apt-get install libfdt-dev 23 | - ./configure --disable-werror --enable-debug --target-list="arm-softmmu" --extra-cflags=-DSTM32_UART_NO_BAUD_DELAY --extra-cflags=-DSTM32_UART_ENABLE_OVERRUN --disable-gtk 24 | - make -j2 25 | - cd .. 26 | - make -j2 27 | - make stmf4 28 | -------------------------------------------------------------------------------- /include/event-monitor.h: -------------------------------------------------------------------------------- 1 | #ifndef EVENT_H 2 | #define EVENT_H 3 | 4 | #include "kconfig.h" 5 | #include "task.h" 6 | 7 | struct event_monitor; 8 | 9 | typedef int (*event_monitor_handler)(struct event_monitor *monitor, 10 | int event, 11 | struct task_control_block *task, 12 | void *data); 13 | 14 | struct event { 15 | int registerd; 16 | int pending; 17 | event_monitor_handler handler; 18 | void *data; 19 | struct list list; 20 | }; 21 | 22 | struct event_monitor { 23 | struct event *events; 24 | struct list *ready_list; 25 | }; 26 | 27 | void event_monitor_init(struct event_monitor *monitor, 28 | struct event *events, 29 | struct list *ready_list); 30 | int event_monitor_find_free(struct event_monitor *monitor); 31 | void event_monitor_register(struct event_monitor *monitor, int event, 32 | event_monitor_handler handler, void *data); 33 | void event_monitor_block(struct event_monitor *monitor, int event, 34 | struct task_control_block *task); 35 | void event_monitor_release(struct event_monitor *monitor, int event); 36 | void event_monitor_serve(struct event_monitor *monitor); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/list.c: -------------------------------------------------------------------------------- 1 | #include "list.h" 2 | 3 | void list_init(struct list *list) { 4 | if (list) { 5 | list->prev = list; 6 | list->next = list; 7 | } 8 | } 9 | 10 | int list_empty(struct list *list) { return list->next == list; } 11 | 12 | void list_remove(struct list *list) { 13 | if (list) { 14 | list->next->prev = list->prev; 15 | list->prev->next = list->next; 16 | } 17 | } 18 | 19 | void list_unshift(struct list *list, struct list *new) { 20 | if (list && new) { 21 | list_remove(new); 22 | 23 | list->next->prev = new; 24 | new->next = list->next; 25 | new->prev = list; 26 | list->next = new; 27 | } 28 | } 29 | 30 | void list_push(struct list *list, struct list *new) { 31 | if (list && new) { 32 | /* Remove new from origin list */ 33 | new->prev->next = new->next; 34 | new->next->prev = new->prev; 35 | 36 | list->prev->next = new; 37 | new->next = list; 38 | new->prev = list->prev; 39 | list->prev = new; 40 | } 41 | } 42 | 43 | struct list *list_shift(struct list *list) { 44 | struct list *first = list->next; 45 | 46 | if (first == list) 47 | return 0; 48 | 49 | list->next = first->next; 50 | list->next->prev = list; 51 | 52 | return first; 53 | } 54 | -------------------------------------------------------------------------------- /src/string.c: -------------------------------------------------------------------------------- 1 | #include "string.h" 2 | #include "platform.h" 3 | 4 | int strcmp(const char *a, const char *b) { 5 | __asm( 6 | "strcmp_lop: \n" 7 | " ldrb r2, [r0],#1 \n" 8 | " ldrb r3, [r1],#1 \n" 9 | " cmp r2, #1 \n" 10 | " it hi \n" 11 | " cmphi r2, r3 \n" 12 | " beq strcmp_lop \n" 13 | " sub r0, r2, r3 \n" 14 | " bx lr \n" :: 15 | :); 16 | } 17 | 18 | int strncmp(const char *a, const char *b, size_t n) { 19 | size_t i; 20 | 21 | for (i = 0; i < n; i++) 22 | if (a[i] != b[i]) 23 | return a[i] - b[i]; 24 | 25 | return 0; 26 | } 27 | 28 | size_t strlen(const char *s) { 29 | __asm( 30 | " sub r3, r0, #1 \n" 31 | "strlen_loop: \n" 32 | " ldrb r2, [r3, #1]! \n" 33 | " cmp r2, #0 \n" 34 | " bne strlen_loop \n" 35 | " sub r0, r3, r0 \n" 36 | " bx lr \n" :: 37 | :); 38 | } 39 | 40 | void puts(char *s) { 41 | while (*s) { 42 | while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET) 43 | /* wait */; 44 | USART_SendData(USART2, *s); 45 | s++; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /include/regfile.h: -------------------------------------------------------------------------------- 1 | #ifndef REGFILE_H 2 | #define REGFILE_H 3 | 4 | #include "file.h" 5 | #include "fs.h" 6 | #include "memory-pool.h" 7 | 8 | struct regfile { 9 | struct file file; 10 | int driver_pid; 11 | struct file *driver_file; 12 | int event; 13 | 14 | /* request */ 15 | int request_pid; 16 | int buzy; 17 | int pos; 18 | char buf[REGFILE_BUF]; 19 | 20 | /* response */ 21 | int transfer_len; 22 | }; 23 | 24 | int regfile_init(int fd, int driver_pid, struct file *files[], 25 | struct memory_pool *memory_pool, struct event_monitor *monitor); 26 | int regfile_response(int fd, char *buf, int len); 27 | int regfile_readable (struct file *file, struct file_request *request, 28 | struct event_monitor *monitor); 29 | int regfile_writable (struct file *file, struct file_request *request, 30 | struct event_monitor *monitor); 31 | int regfile_read (struct file *file, struct file_request *request, 32 | struct event_monitor *monitor); 33 | int regfile_write (struct file *file, struct file_request *request, 34 | struct event_monitor *monitor); 35 | int regfile_lseekable (struct file *file, struct file_request *request, 36 | struct event_monitor *monitor); 37 | int regfile_lseek (struct file *file, struct file_request *request, 38 | struct event_monitor *monitor); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /include/task.h: -------------------------------------------------------------------------------- 1 | #ifndef TASK_H 2 | #define TASK_H 3 | 4 | #include "kconfig.h" 5 | #include "list.h" 6 | 7 | #define TASK_READY 0 8 | #define TASK_WAIT_READ 1 9 | #define TASK_WAIT_WRITE 2 10 | #define TASK_WAIT_INTR 3 11 | #define TASK_WAIT_TIME 4 12 | #define TASK_WAIT_TASK 5 13 | #define TASK_WAIT_MUTEX 6 14 | 15 | /* Stack struct of user thread, see "Exception entry and return" */ 16 | struct user_thread_stack { 17 | unsigned int r4; 18 | unsigned int r5; 19 | unsigned int r6; 20 | unsigned int r7; 21 | unsigned int r8; 22 | unsigned int r9; 23 | unsigned int r10; 24 | unsigned int fp; 25 | unsigned int _lr; /* Back to system calls or return exception */ 26 | unsigned int _r7; /* Backup from isr */ 27 | unsigned int r0; 28 | unsigned int r1; 29 | unsigned int r2; 30 | unsigned int r3; 31 | unsigned int ip; 32 | unsigned int lr; /* Back to user thread code */ 33 | unsigned int pc; 34 | unsigned int xpsr; 35 | unsigned int stack[STACK_SIZE - 18]; 36 | }; 37 | 38 | /* Task Control Block */ 39 | struct task_control_block { 40 | struct user_thread_stack *stack; 41 | int pid; 42 | int status; 43 | int priority; 44 | int inuse; 45 | 46 | struct list list; 47 | }; 48 | 49 | unsigned int *init_task(unsigned int *stack, void (*start)()); 50 | struct task_control_block* task_create(int priority, void *func, void *arg); 51 | int task_kill(int pid); 52 | void task_exit(void* ptr); 53 | void task_block(int pid); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /app/posixtestsuit/pthread_create/1-1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 | * Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com 4 | * This file is licensed under the GPL license. For the full content 5 | * of this license, see the COPYING file at the top level of this 6 | * source tree. 7 | 8 | * Test that pthread_create() creates a new thread with attributes specified 9 | * by 'attr', within a process. 10 | * 11 | * Steps: 12 | * 1. Create a thread using pthread_create() 13 | * 2. Compare the thread ID of 'main' to the thread ID of the newly created 14 | * thread. They should be different. 15 | */ 16 | 17 | 18 | #include "posixtest.h" 19 | #include "rtenv.h" 20 | 21 | void *a_thread_func() 22 | { 23 | 24 | pthread_exit(0); 25 | return NULL; 26 | } 27 | 28 | int main() 29 | { 30 | pthread_t main_th, new_th; 31 | 32 | if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) 33 | { 34 | perror("Error creating thread\r\n"); 35 | return PTS_UNRESOLVED; 36 | } 37 | 38 | /* Obtain the thread ID of this main function */ 39 | main_th=pthread_self(); 40 | 41 | /* Compare the thread ID of the new thread to the main thread. 42 | * They should be different. If not, the test fails. */ 43 | if(pthread_equal(new_th, main_th) != 0) 44 | { 45 | printf("Test FAILED: A new thread wasn't created\r\n"); 46 | return PTS_FAIL; 47 | } 48 | 49 | printf("Test PASSED\n"); 50 | return PTS_PASS; 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /include/kconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef KCONFIG_H 2 | #define KCONFIG_H 3 | 4 | #define STACK_SIZE 384 /* Size of task stacks in words */ 5 | #define TASK_LIMIT 24 /* Max number of tasks we can handle */ 6 | #define TASK_BLOCK_LIMIT (TASK_LIMIT - 1) /* Max number of tasks whick can be block from other task */ 7 | #define PIPE_LIMIT (TASK_LIMIT * 2) 8 | #define PIPE_BUF 64 /* Size of largest atomic pipe message */ 9 | #define PATH_MAX 32 /* Longest absolute path */ 10 | #define PATHSERVER_FD (TASK_LIMIT + 4) 11 | /* File descriptor of pipe to pathserver */ 12 | #define FREG_LIMIT 16 /* Other types file limit */ 13 | #define FILE_LIMIT (PIPE_LIMIT + FREG_LIMIT) 14 | #define MEM_LIMIT (4096) 15 | #define BLOCK_BUF 64 16 | #define REGFILE_BUF 64 17 | #define FS_LIMIT 8 18 | #define FS_TYPE_MAX 8 19 | #define MOUNT_LIMIT 4 20 | #define MUTEX_LIMIT 8 21 | 22 | /* PATHSERVER_FD + 1 to FILE_LIMIT is control by pathserver() 23 | * If we want to add new system FD: 24 | * let PATHSERVER_FD += 1, 25 | * and NEW_SYSTEM_FD = (PATHSERVER - N) 26 | * 27 | * OR 28 | * 29 | * Use 0-2 reserved FDs 30 | * 31 | * see SIGSERVER_FD 32 | */ 33 | #define SIGSERVER_FD (PATHSERVER_FD - 1) 34 | 35 | #define ROMFS_FILE_LIMIT 8 36 | 37 | #define INTR_LIMIT 58 /* IRQn = [-15 ... 42] */ 38 | #define EVENT_LIMIT (FILE_LIMIT * 2 + INTR_LIMIT + TASK_BLOCK_LIMIT + 1) 39 | /* Read and write event for each file, intr events and time event */ 40 | 41 | #define PRIORITY_DEFAULT 20 42 | #define PRIORITY_LIMIT (PRIORITY_DEFAULT * 2 - 1) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /platform/stm32f429/stm32_p103.c: -------------------------------------------------------------------------------- 1 | #include "stm32_p103.h" 2 | #include "stm32f4xx.h" 3 | #include "stm32f4xx_gpio.h" 4 | #include "stm32f4xx_usart.h" 5 | #include "stm32f4xx_rcc.h" 6 | 7 | void init_rs232(void) { 8 | USART_InitTypeDef USART_InitStructure; 9 | GPIO_InitTypeDef GPIO_InitStructure; 10 | 11 | /* Enable peripheral clocks. */ 12 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); 13 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); 14 | 15 | GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1); // USART2_TX 16 | GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1); // USART2_RX 17 | /* Configure USART2 Rx pin as floating input. */ 18 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10; 19 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 20 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 21 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 22 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 23 | GPIO_Init(GPIOA, &GPIO_InitStructure); 24 | 25 | 26 | /* Configure the USART2 */ 27 | USART_InitStructure.USART_BaudRate = 115200; 28 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; 29 | USART_InitStructure.USART_StopBits = USART_StopBits_1; 30 | USART_InitStructure.USART_Parity = USART_Parity_No; 31 | USART_InitStructure.USART_HardwareFlowControl = 32 | USART_HardwareFlowControl_None; 33 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; 34 | USART_Init(USART1, &USART_InitStructure); 35 | USART_Cmd(USART1, ENABLE); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /include/pipe.h: -------------------------------------------------------------------------------- 1 | #ifndef PIPE_H 2 | #define PIPE_H 3 | 4 | #include "kconfig.h" 5 | #include "file.h" 6 | 7 | struct pipe_ringbuffer { 8 | struct file file; 9 | int start; 10 | int end; 11 | int read_event; 12 | int write_event; 13 | char data[PIPE_BUF]; 14 | }; 15 | 16 | #define RB_PUSH(rb, size, v) do { \ 17 | (rb).data[(rb).end] = (v); \ 18 | (rb).end++; \ 19 | if ((rb).end >= size) (rb).end = 0; \ 20 | } while (0) 21 | 22 | #define RB_POP(rb, size, v) do { \ 23 | (v) = (rb).data[(rb).start]; \ 24 | (rb).start++; \ 25 | if ((rb).start >= size) (rb).start = 0; \ 26 | } while (0) 27 | 28 | #define RB_PEEK(rb, size, v, i) do { \ 29 | int _counter = (i); \ 30 | int _src_index = (rb).start; \ 31 | int _dst_index = 0; \ 32 | while (_counter--) { \ 33 | ((char*)&(v))[_dst_index++] = (rb).data[_src_index++]; \ 34 | if (_src_index >= size) _src_index = 0; \ 35 | } \ 36 | } while (0) 37 | 38 | #define RB_LEN(rb, size) (((rb).end - (rb).start) + \ 39 | (((rb).end < (rb).start) ? size : 0)) 40 | 41 | #define PIPE_PUSH(pipe, v) RB_PUSH((pipe), PIPE_BUF, (v)) 42 | #define PIPE_POP(pipe, v) RB_POP((pipe), PIPE_BUF, (v)) 43 | #define PIPE_PEEK(pipe, v, i) RB_PEEK((pipe), PIPE_BUF, (v), (i)) 44 | #define PIPE_LEN(pipe) (RB_LEN((pipe), PIPE_BUF)) 45 | 46 | int pipe_read_release(struct event_monitor *monitor, int event, 47 | struct task_control_block *task, void *data); 48 | 49 | int pipe_write_release(struct event_monitor *monitor, int event, 50 | struct task_control_block *task, void *data); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /include/block.h: -------------------------------------------------------------------------------- 1 | #ifndef BLOCK_H 2 | #define BLOCK_H 3 | 4 | #include "file.h" 5 | #include "memory-pool.h" 6 | 7 | #define BLOCK_CMD_READ 1 8 | #define BLOCK_CMD_WRITE 2 9 | #define BLOCK_CMD_SEEK 3 10 | 11 | struct block { 12 | struct file file; 13 | int driver_pid; 14 | struct file *driver_file; 15 | int event; 16 | 17 | /* request */ 18 | int request_pid; 19 | int buzy; 20 | int pos; 21 | char buf[BLOCK_BUF]; 22 | 23 | /* response */ 24 | int transfer_len; 25 | }; 26 | 27 | struct block_request { 28 | int cmd; 29 | int task; 30 | int fd; 31 | int size; 32 | int pos; 33 | }; 34 | 35 | int block_init(int fd, int driver_pid, struct file *files[], 36 | struct memory_pool *memory_pool, struct event_monitor *monitor); 37 | int block_response(int fd, char *buf, int len); 38 | int block_readable (struct file *file, struct file_request *request, 39 | struct event_monitor *monitor); 40 | int block_writable (struct file *file, struct file_request *request, 41 | struct event_monitor *monitor); 42 | int block_read (struct file *file, struct file_request *request, 43 | struct event_monitor *monitor); 44 | int block_write (struct file *file, struct file_request *request, 45 | struct event_monitor *monitor); 46 | int block_lseekable (struct file *file, struct file_request *request, 47 | struct event_monitor *monitor); 48 | int block_lseek (struct file *file, struct file_request *request, 49 | struct event_monitor *monitor); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /mk/rules.mk: -------------------------------------------------------------------------------- 1 | $(PLAT_LIST): 2 | $(MAKE) -f $(TOP)/$(PLAT_DIR)/$@/Makefile TOP=$(TOP) 3 | 4 | all: $(OUTDIR)/$(TARGET).bin $(OUTDIR)/$(TARGET).lst 5 | 6 | $(OUTDIR)/$(TARGET).bin: $(OUTDIR)/$(TARGET).elf 7 | @echo " OBJCOPY "$@ 8 | @$(CROSS_COMPILE)objcopy -Obinary $< $@ 9 | 10 | $(OUTDIR)/$(TARGET).lst: $(OUTDIR)/$(TARGET).elf 11 | @echo " LIST "$@ 12 | @$(CROSS_COMPILE)objdump -S $< > $@ 13 | 14 | $(OUTDIR)/$(TARGET).elf: $(OBJ) $(DAT) 15 | @echo " LD "$@ 16 | @echo " MAP "$(OUTDIR)/$(TARGET).map 17 | @$(CROSS_COMPILE)gcc $(CFLAGS) -Wl,-Map=$(OUTDIR)/$(TARGET).map -o $@ $^ 18 | 19 | $(OUTDIR)/%.o: %.c 20 | @mkdir -p $(dir $@) 21 | @echo " CC "$@ 22 | @$(CROSS_COMPILE)gcc $(CFLAGS) -MMD -MF $@.d -o $@ -c $(INCLUDES) $< 23 | 24 | $(OUTDIR)/%.o: %.s 25 | @mkdir -p $(dir $@) 26 | @echo " CC "$@ 27 | @$(CROSS_COMPILE)gcc $(CFLAGS) -MMD -MF $@.d -o $@ -c $(INCLUDES) $< 28 | 29 | flash: 30 | st-flash write $(OUTDIR)/main.bin 0x8000000 31 | 32 | runstm: 33 | @echo " Debuggin..." 34 | @$(CROSS_COMPILE)gdb $(OUTDIR)/main.bin \ 35 | -ex 'target remote :3333' \ 36 | -ex 'monitor reset halt' \ 37 | -ex 'load' \ 38 | -ex 'monitor arm semihosting enable' \ 39 | -ex 'continue' 40 | 41 | runstmdbg: 42 | @echo " Debuggin..." 43 | @$(CROSS_COMPILE)gdb $(OUTDIR)/main.elf \ 44 | -ex 'target remote :4242' \ 45 | -ex 'monitor reset halt' \ 46 | -ex 'load' \ 47 | -ex 'monitor arm semihosting enable' 48 | @echo " Start to dgb!!" 49 | 50 | openocd: 51 | openocd -f board/stm32f4discovery.cfg 52 | 53 | clean: 54 | rm -rf $(OUTDIR) 55 | 56 | -include $(DEP) 57 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ============================================================================ 2 | 3 | rtenv+ is freely redistributable under the two-clause BSD License: 4 | 5 | Copyright (C) 2013-2015, 2018 National Cheng Kung University, Taiwan. 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | 1. Redistributions of source code must retain the above copyright notice, 13 | this list of conditions and the following disclaimer. 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 | THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | ---------------------------------------------------------------------------- 31 | -------------------------------------------------------------------------------- /app/posixtestsuit/1-2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 | * Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com 4 | * This file is licensed under the GPL license. For the full content 5 | * of this license, see the COPYING file at the top level of this 6 | * source tree. 7 | 8 | * Test that pthread_create() creates a new thread with attributes specified 9 | * by 'attr', within a process. 10 | * 11 | * Steps: 12 | * 1. Create a thread using pthread_create() 13 | * 2. Cancel that thread with pthread_cancel() 14 | * 3. If that thread doesn't exist, then it pthread_cancel() will return 15 | * an error code. This would mean that pthread_create() did not create 16 | * a thread successfully. 17 | */ 18 | 19 | #include "rtenv.h" 20 | #include "posixtest.h" 21 | 22 | void *a_thread_func() 23 | { 24 | sleep(10); 25 | 26 | /* Shouldn't reach here. If we do, then the pthread_cancel() 27 | * function did not succeed. */ 28 | perror("Could not send cancel request correctly\n"); 29 | pthread_exit(0); 30 | return NULL; 31 | } 32 | 33 | int main() 34 | { 35 | pthread_t new_th; 36 | 37 | if(pthread_create(&new_th, NULL, a_thread_func, NULL) < 0) 38 | { 39 | perror("Error creating thread\n"); 40 | return PTS_UNRESOLVED; 41 | } 42 | 43 | /* Try to cancel the newly created thread. If an error is returned, 44 | * then the thread wasn't created successfully. */ 45 | if(pthread_cancel(new_th) != 0) 46 | { 47 | printf("Test FAILED: A new thread wasn't created\n"); 48 | return PTS_FAIL; 49 | } 50 | 51 | printf("Test PASSED\n"); 52 | return PTS_PASS; 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/memcpy.s: -------------------------------------------------------------------------------- 1 | .syntax unified 2 | .align 4 3 | 4 | .global memcpy 5 | memcpy: 6 | push {r0} 7 | cmp r2, #4 8 | it lo 9 | lslslo r2, r2, #30 /* Adjust r2 for less_than_4_bytes */ 10 | blo less_than_4_bytes 11 | 12 | ands r3, r1, #3 13 | beq aligned 14 | 15 | negs r3, r3 /* Next aligned offset = (4 - src & 3) & 3 */ 16 | lsls r3, r3, #31 17 | ittt cs 18 | ldrhcs r3, [r1], #2 /* Load if 2 bytes unaligned */ 19 | subcs r2, r2, #2 20 | strhcs r3, [r0], #2 /* Save if 2 bytes unaligned */ 21 | ittt mi 22 | ldrbmi r3, [r1] ,#1 /* Load if 1 byte unaligned */ 23 | submi r2, r2, #1 24 | strbmi r3, [r0] ,#1 /* Save if 1 byte unaligned */ 25 | 26 | aligned: 27 | push {r4 - r10} 28 | subs r2, #32 29 | blo less_than_32_bytes 30 | L: 31 | ldmia r1!, {r3 - r10} 32 | subs r2, #32 33 | stmia r0!, {r3 - r10} 34 | bhs L 35 | 36 | less_than_32_bytes: 37 | lsls r2, r2, #28 38 | it cs 39 | ldmiacs r1!, {r3 - r6} /* Load if 16 bytes remained */ 40 | it mi 41 | ldmiami r1!, {r7 - r8} /* Load if 8 bytes remained */ 42 | it cs 43 | stmiacs r0!, {r3 - r6} 44 | it mi 45 | stmiami r0!, {r7 - r8} 46 | 47 | lsls r2, r2, #2 48 | itt cs 49 | ldrcs r3, [r1], #4 /* Load if 4 bytes remained */ 50 | strcs r3, [r0], #4 51 | 52 | pop {r4 - r10} 53 | 54 | less_than_4_bytes: 55 | it ne 56 | ldrne r3, [r1] /* Load if ether 2 bytes or 1 byte remained */ 57 | lsls r2, r2, #1 58 | itt cs 59 | strhcs r3, [r0],#2 /* Save if 2 bytes remained */ 60 | lsrcs r3, r3, 16 61 | it mi 62 | strbmi r3, [r0],#1 /* Save if 1 byte remained */ 63 | 64 | pop {r0} 65 | bx lr 66 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TARGET = main 2 | TARGET_STMF4 = main 3 | .DEFAULT_GOAL = all 4 | 5 | APP_DIR = 6 | 7 | include app/build.mk 8 | 9 | CROSS_COMPILE ?= arm-none-eabi- 10 | CC := $(CROSS_COMPILE)gcc 11 | CFLAGS = -fno-common -ffreestanding -O0 \ 12 | -gdwarf-2 -g3 -Wall -Werror \ 13 | -mcpu=cortex-m3 -mthumb \ 14 | -Wl,-Tmain.ld -nostartfiles \ 15 | -DUSER_NAME=\"$(USER)\" \ 16 | -std=c11 17 | 18 | ARCH ?= CM3 19 | VENDOR ?= ST 20 | PLAT ?= stm32f10x 21 | PLAT_DIR := platform 22 | 23 | TOP ?= $(shell pwd -L) 24 | LIBDIR = . 25 | CMSIS_LIB = $(LIBDIR)/libraries/CMSIS/$(ARCH) 26 | STM32_LIB = $(LIBDIR)/libraries/$(PLAT)_StdPeriph_Driver 27 | CMSIS_PLAT_SRC = $(CMSIS_LIB)/DeviceSupport/$(VENDOR)/$(PLAT) 28 | CMSIS_PLAT_INC = $(CMSIS_PLAT_SRC)/Include 29 | 30 | 31 | OUTDIR = build 32 | SRCDIR = src \ 33 | $(CMSIS_LIB)/CoreSupport \ 34 | $(STM32_LIB)/src \ 35 | $(CMSIS_PLAT_SRC) \ 36 | $(PLAT_DIR)/$(PLAT) \ 37 | $(APP_DIR) 38 | INCDIR = include \ 39 | $(CMSIS_LIB)/CoreSupport \ 40 | $(STM32_LIB)/inc \ 41 | $(CMSIS_PLAT_INC) \ 42 | $(PLAT_DIR)/$(PLAT) \ 43 | $(APP_DIR) 44 | INCLUDES = $(addprefix -I, $(INCDIR)) 45 | 46 | DATDIR = data 47 | TOOLDIR = tool 48 | 49 | SRC = $(wildcard $(addsuffix /*.c,$(SRCDIR))) \ 50 | $(wildcard $(addsuffix /*.s,$(SRCDIR))) \ 51 | $(CMSIS_PLAT_SRC)/startup/gcc_ride7/startup_$(PLAT).s 52 | OBJ := $(addprefix $(OUTDIR)/,$(patsubst %.s,%.o,$(SRC:.c=.o))) 53 | DEP = $(OBJ:.o=.o.d) 54 | 55 | DAT = 56 | 57 | MAKDIR = mk 58 | MAK = $(wildcard $(MAKDIR)/*.mk) 59 | 60 | PLAT_LIST := $(subst $(TOP)/$(PLAT_DIR)/,,$(wildcard $(TOP)/$(PLAT_DIR)/*)) 61 | 62 | include $(MAK) 63 | -include $(DEP) 64 | -------------------------------------------------------------------------------- /src/signal.c: -------------------------------------------------------------------------------- 1 | #include "signal.h" 2 | #include "rtenv.h" 3 | 4 | #define write_sig_info_to_server(mode, self, sig) \ 5 | { \ 6 | write(SIGSERVER_FD, &mode, sizeof(int)); \ 7 | write(SIGSERVER_FD, &self, sizeof(int)); \ 8 | write(SIGSERVER_FD, &sig, sizeof(int)); \ 9 | } 10 | 11 | /* signal is a function accepting two arguments 12 | * -- an int and a function pointer -- 13 | * and returning a function pointer. 14 | */ 15 | sighandler_t signal(int sig, sighandler_t func) { 16 | int mode = SIGSET; 17 | int status = -1; 18 | int self = getpid() + 3; 19 | unsigned int func_addr = (unsigned int) func; 20 | 21 | if (func == SIG_DFL || func == SIG_IGN) { 22 | sighandler_t retval = SIG_ERR; 23 | (func == SIG_DFL) ? (mode = SIGDFL) : (mode = SIGIGN); 24 | write_sig_info_to_server(mode, self, sig); 25 | read(self, &func_addr, sizeof(void (*)(int))); 26 | 27 | retval = (void (*)(int)) func_addr; 28 | 29 | return retval; 30 | } 31 | else { 32 | switch (sig) { 33 | case SIGCHLD: 34 | write_sig_info_to_server(mode, self, sig); 35 | write(SIGSERVER_FD, &func_addr, sizeof(void (*)(int))); 36 | read(self, &status, sizeof(int)); 37 | break; 38 | default: 39 | break; 40 | } 41 | } 42 | return NULL; 43 | } 44 | 45 | int raise(int sig) { 46 | sighandler_t sighandle = NULL; 47 | unsigned int func_addr = 0; 48 | int self = getpid() + 3; 49 | int mode = SIGRAISE; 50 | 51 | write_sig_info_to_server(mode, self, sig); 52 | read(self, &func_addr, sizeof(void (*)(int))); 53 | 54 | sighandle = (void (*)(int)) func_addr; 55 | 56 | if (sighandle != SIG_ERR) { 57 | sighandle(sig); 58 | return 0; 59 | } 60 | return 1; 61 | } 62 | -------------------------------------------------------------------------------- /src/syscall.s: -------------------------------------------------------------------------------- 1 | .syntax unified 2 | .cpu cortex-m3 3 | .fpu softvfp 4 | .thumb 5 | 6 | .global fork 7 | fork: 8 | push {r7, lr} 9 | mov r7, #0x1 10 | svc 0 11 | nop 12 | pop {r7, lr} 13 | bx lr 14 | .global getpid 15 | getpid: 16 | push {r7, lr} 17 | mov r7, #0x2 18 | svc 0 19 | nop 20 | pop {r7, lr} 21 | bx lr 22 | .global write 23 | write: 24 | push {r7, lr} 25 | mov r7, #0x3 26 | svc 0 27 | nop 28 | pop {r7, lr} 29 | bx lr 30 | .global read 31 | read: 32 | push {r7, lr} 33 | mov r7, #0x4 34 | svc 0 35 | nop 36 | pop {r7, lr} 37 | bx lr 38 | .global interrupt_wait 39 | interrupt_wait: 40 | push {r7, lr} 41 | mov r7, #0x5 42 | svc 0 43 | nop 44 | pop {r7, lr} 45 | bx lr 46 | .global getpriority 47 | getpriority: 48 | push {r7, lr} 49 | mov r7, #0x6 50 | svc 0 51 | nop 52 | pop {r7, lr} 53 | bx lr 54 | .global setpriority 55 | setpriority: 56 | push {r7, lr} 57 | mov r7, #0x7 58 | svc 0 59 | nop 60 | pop {r7, lr} 61 | bx lr 62 | .global mknod 63 | mknod: 64 | push {r7, lr} 65 | mov r7, #0x8 66 | svc 0 67 | nop 68 | pop {r7, lr} 69 | bx lr 70 | .global sleep 71 | sleep: 72 | push {r7, lr} 73 | mov r7, #0x9 74 | svc 0 75 | nop 76 | pop {r7,lr} 77 | bx lr 78 | .global lseek 79 | lseek: 80 | push {r7, lr} 81 | mov r7, #0xa 82 | svc 0 83 | nop 84 | pop {r7,lr} 85 | bx lr 86 | .global task_block 87 | task_block: 88 | push {r7, lr} 89 | mov r7, #0xb 90 | svc 0 91 | nop 92 | pop {r7,lr} 93 | bx lr 94 | .global mutex_lock 95 | mutex_lock: 96 | push {r7, lr} 97 | mov r7, #0xc 98 | svc 0 99 | nop 100 | pop {r7, lr} 101 | bx lr 102 | .global mutex_unlock 103 | mutex_unlock: 104 | push {r7, lr} 105 | mov r7, #0xd 106 | svc 0 107 | nop 108 | pop {r7, lr} 109 | bx lr 110 | -------------------------------------------------------------------------------- /include/file.h: -------------------------------------------------------------------------------- 1 | #ifndef FILE_H 2 | #define FILE_H 3 | 4 | #include "stddef.h" 5 | #include "task.h" 6 | #include "event-monitor.h" 7 | #include "memory-pool.h" 8 | 9 | /* file types */ 10 | #define S_IFIFO 1 11 | #define S_IMSGQ 2 12 | #define S_IFBLK 6 13 | #define S_IFREG 010 14 | 15 | /* file flags */ 16 | #define O_CREAT 4 17 | 18 | /* seek whence */ 19 | #define SEEK_SET 1 20 | #define SEEK_CUR 2 21 | #define SEEK_END 3 22 | 23 | #define FILE_ACCESS_ACCEPT 1 24 | #define FILE_ACCESS_BLOCK 0 25 | #define FILE_ACCESS_ERROR -1 26 | 27 | #define FILE_EVENT_READ(fd) ((fd) * 2) 28 | #define FILE_EVENT_WRITE(fd) ((fd) * 2 + 1) 29 | 30 | #define FILE_EVENT_IS_READ(event) ((event) % 2 == 0) 31 | 32 | struct file_request { 33 | struct task_control_block *task; 34 | char *buf; 35 | int size; 36 | int whence; 37 | }; 38 | 39 | struct file { 40 | int fd; 41 | struct file_operations *ops; 42 | }; 43 | 44 | struct file_operations { 45 | int (*readable)(struct file*, struct file_request*, struct event_monitor *); 46 | int (*writable)(struct file*, struct file_request*, struct event_monitor *); 47 | int (*read)(struct file*, struct file_request*, struct event_monitor *); 48 | int (*write)(struct file*, struct file_request*, struct event_monitor *); 49 | int (*lseekable)(struct file*, struct file_request*, struct event_monitor *); 50 | int (*lseek)(struct file*, struct file_request*, struct event_monitor *); 51 | }; 52 | 53 | int mkfile(const char *pathname, int mode, int dev); 54 | int open(const char *pathname, int flags); 55 | 56 | int file_read(struct file *file, struct file_request *request, 57 | struct event_monitor *monitor); 58 | int file_write(struct file *file, struct file_request *request, 59 | struct event_monitor *monitor); 60 | int file_mknod(int fd, int driver_pid, struct file *files[], int dev, 61 | struct memory_pool *memory_pool, 62 | struct event_monitor *event_monitor); 63 | int file_lseek(struct file *file, struct file_request *request, 64 | struct event_monitor *monitor); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /mk/qemu.mk: -------------------------------------------------------------------------------- 1 | QEMU_STM32 ?= ../qemu_stm32-stm32_v0.1.3/arm-softmmu/qemu-system-arm 2 | 3 | qemu: $(OUTDIR)/$(TARGET).bin $(QEMU_STM32) 4 | $(QEMU_STM32) -M stm32-p103 -nographic\ 5 | -cpu cortex-m3 \ 6 | -kernel $(OUTDIR)/$(TARGET).bin -semihosting 7 | 8 | qemud: $(OUTDIR)/$(TARGET).bin $(QEMU_STM32) 9 | $(QEMU_STM32) -M stm32-p103 \ 10 | -gdb tcp::3333 -S \ 11 | -kernel $(OUTDIR)/$(TARGET).bin -semihosting 12 | 13 | qemugrasp: $(OUTDIR)/$(TARGET).bin $(QEMU_STM32) 14 | bash tool/emulate_grasp.sh $(OUTDIR)/$(TARGET).bin 15 | python log2grasp.py 16 | ../grasp_linux/grasp sched.grasp 17 | 18 | run: 19 | $(CROSS_COMPILE)gdb -x $(TOOLDIR)/gdbscript 20 | 21 | qemunographic: $(OUTDIR)/$(TARGET).bin $(QEMU_STM32) 22 | $(QEMU_STM32) -M stm32-p103 \ 23 | -monitor stdio -nographic \ 24 | -kernel $(OUTDIR)/$(TARGET).bin -semihosting 25 | 26 | qemudbg: $(OUTDIR)/$(TARGET).bin $(QEMU_STM32) 27 | $(QEMU_STM32) -M stm32-p103 \ 28 | -monitor stdio \ 29 | -gdb tcp::3333 -S \ 30 | -kernel $(OUTDIR)/$(TARGET).bin -semihosting 2>&1>/dev/null & \ 31 | echo $$! > $(OUTDIR)/qemu_pid && \ 32 | $(CROSS_COMPILE)gdb -x $(TOOLDIR)/gdbscript && \ 33 | cat $(OUTDIR)/qemu_pid | `xargs kill 2>/dev/null || test true` && \ 34 | rm -f $(OUTDIR)/qemu_pid 35 | 36 | qemu_remote: $(OUTDIR)/$(TARGET).bin $(QEMU_STM32) 37 | $(QEMU_STM32) -M stm32-p103 -kernel $(OUTDIR)/$(TARGET).bin -vnc :1 38 | 39 | qemudbg_remote: $(OUTDIR)/$(TARGET).bin $(QEMU_STM32) 40 | $(QEMU_STM32) -M stm32-p103 \ 41 | -gdb tcp::3333 -S \ 42 | -kernel $(OUTDIR)/$(TARGET).bin \ 43 | -vnc :1 44 | 45 | qemu_remote_bg: $(OUTDIR)/$(TARGET).bin $(QEMU_STM32) 46 | $(QEMU_STM32) -M stm32-p103 \ 47 | -kernel $(OUTDIR)/$(TARGET).bin \ 48 | -vnc :1 & 49 | 50 | qemudbg_remote_bg: $(OUTDIR)/$(TARGET).bin $(QEMU_STM32) 51 | $(QEMU_STM32) -M stm32-p103 \ 52 | -gdb tcp::3333 -S \ 53 | -kernel $(OUTDIR)/$(TARGET).bin \ 54 | -vnc :1 & 55 | 56 | emu: $(OUTDIR)/$(TARGET).bin 57 | bash $(TOOLDIR)/emulate.sh $(OUTDIR)/$(TARGET).bin 58 | 59 | qemuauto: $(OUTDIR)/$(TARGET).bin $(TOOLDIR)gdbscript 60 | bash $(TOOLDIR)emulate.sh $(OUTDIR)/$(TARGET).bin & 61 | sleep 1 62 | $(CROSS_COMPILE)gdb -x gdbscript& 63 | sleep 5 64 | 65 | qemuauto_remote: $(OUTDIR)/$(TARGET).bin $(TOOLDIR)gdbscript 66 | bash $(TOOLDIR)emulate_remote.sh $(OUTDIR)/$(TARGET).bin & 67 | sleep 1 68 | $(CROSS_COMPILE)gdb -x gdbscript& 69 | sleep 5 70 | -------------------------------------------------------------------------------- /src/host.c: -------------------------------------------------------------------------------- 1 | #include "host.h" 2 | #include 3 | 4 | typedef union param_t { 5 | int pdInt; 6 | void *pdPtr; 7 | char *pdChrPtr; 8 | } param; 9 | 10 | typedef int hostfunc(va_list); 11 | 12 | typedef struct { 13 | enum HOST_SYSCALL action; 14 | hostfunc *fptr; 15 | } hostcmdlist; 16 | 17 | #define MKHCL(a, n) \ 18 | { .action = a, .fptr = host_##n } 19 | 20 | const hostcmdlist hcl[23] = { 21 | [SYS_OPEN] = MKHCL(SYS_OPEN, open), 22 | [SYS_CLOSE] = MKHCL(SYS_CLOSE, close), 23 | [SYS_WRITE] = MKHCL(SYS_WRITE, write), 24 | [SYS_SYSTEM] = MKHCL(SYS_SYSTEM, system), 25 | }; 26 | 27 | /*action will be in r0, and argv in r1*/ 28 | int host_call(enum HOST_SYSCALL action, void *argv) { 29 | /* For Thumb-2 code use the BKPT instruction instead of SWI. 30 | * Refer to: 31 | * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471c/Bgbjhiea.html 32 | * http://en.wikipedia.org/wiki/ARM_Cortex-M#Cortex-M4 */ 33 | int result; 34 | __asm__( 35 | "bkpt 0xAB\n" 36 | "nop\n" 37 | "bx lr\n" 38 | : "=r"(result)::); 39 | return result; 40 | } 41 | 42 | int host_system(va_list v1) { 43 | char *tmpChrPtr; 44 | 45 | tmpChrPtr = va_arg(v1, char *); 46 | return host_call(SYS_SYSTEM, (param[]){{.pdChrPtr = tmpChrPtr}, 47 | {.pdInt = strlen(tmpChrPtr)}}); 48 | } 49 | 50 | int host_open(va_list v1) { 51 | char *tmpChrPtr; 52 | 53 | tmpChrPtr = va_arg(v1, char *); 54 | return host_call(SYS_OPEN, (param[]){{.pdChrPtr = tmpChrPtr}, 55 | {.pdInt = va_arg(v1, int)}, 56 | {.pdInt = strlen(tmpChrPtr)}}); 57 | } 58 | 59 | int host_close(va_list v1) { 60 | return host_call(SYS_CLOSE, (param[]){{.pdInt = va_arg(v1, int)}}); 61 | } 62 | 63 | int host_write(va_list v1) { 64 | return host_call(SYS_WRITE, (param[]){{.pdInt = va_arg(v1, int)}, 65 | {.pdPtr = va_arg(v1, void *)}, 66 | {.pdInt = va_arg(v1, int)}}); 67 | } 68 | 69 | int host_action(enum HOST_SYSCALL action, ...) { 70 | int result; 71 | 72 | va_list v1; 73 | va_start(v1, action); 74 | 75 | result = hcl[action].fptr(v1); 76 | 77 | va_end(v1); 78 | 79 | return result; 80 | } 81 | -------------------------------------------------------------------------------- /src/event-monitor.c: -------------------------------------------------------------------------------- 1 | #include "event-monitor.h" 2 | 3 | #include "list.h" 4 | 5 | 6 | void event_monitor_init(struct event_monitor *monitor, struct event *events, 7 | struct list *ready_list) { 8 | int i; 9 | 10 | monitor->events = events; 11 | monitor->ready_list = ready_list; 12 | 13 | for (i = 0; i < EVENT_LIMIT; i++) { 14 | events[i].registerd = 0; 15 | events[i].pending = 0; 16 | events[i].handler = 0; 17 | events[i].data = 0; 18 | list_init(&events[i].list); 19 | } 20 | } 21 | 22 | int event_monitor_find_free(struct event_monitor *monitor) { 23 | int i; 24 | for (i = 0; i < EVENT_LIMIT && monitor->events[i].registerd; i++) 25 | ; 26 | 27 | if (i == EVENT_LIMIT) 28 | return -1; 29 | 30 | return i; 31 | } 32 | 33 | void event_monitor_register(struct event_monitor *monitor, int event, 34 | event_monitor_handler handler, void *data) { 35 | monitor->events[event].registerd = 1; 36 | monitor->events[event].handler = handler; 37 | monitor->events[event].data = data; 38 | } 39 | 40 | void event_monitor_block(struct event_monitor *monitor, int event, 41 | struct task_control_block *task) { 42 | if (task->status == TASK_READY) 43 | list_push(&monitor->events[event].list, &task->list); 44 | } 45 | 46 | void event_monitor_release(struct event_monitor *monitor, int event) { 47 | monitor->events[event].pending = 1; 48 | } 49 | 50 | void event_monitor_serve(struct event_monitor *monitor) { 51 | int i; 52 | for (i = 0; i < EVENT_LIMIT; i++) { 53 | if (monitor->events[i].pending) { 54 | struct event *event = &monitor->events[i]; 55 | struct task_control_block *task; 56 | struct list *curr, *next; 57 | 58 | list_for_each_safe(curr, next, &event->list) { 59 | task = list_entry(curr, struct task_control_block, list); 60 | if (event->handler && 61 | event->handler(monitor, i, task, event->data)) { 62 | list_push(&monitor->ready_list[task->priority], 63 | &task->list); 64 | task->status = TASK_READY; 65 | } 66 | } 67 | 68 | event->pending = 0; 69 | 70 | /* If someone pending events, rescan events */ 71 | i = 0; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /libraries/CMSIS/CM3/DeviceSupport/ST/stm32f10x/Include/system_stm32f10x.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /** @addtogroup CMSIS 23 | * @{ 24 | */ 25 | 26 | /** @addtogroup stm32f10x_system 27 | * @{ 28 | */ 29 | 30 | /** 31 | * @brief Define to prevent recursive inclusion 32 | */ 33 | #ifndef __SYSTEM_STM32F10X_H 34 | #define __SYSTEM_STM32F10X_H 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** @addtogroup STM32F10x_System_Includes 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @addtogroup STM32F10x_System_Exported_types 50 | * @{ 51 | */ 52 | 53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @addtogroup STM32F10x_System_Exported_Constants 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F10x_System_Exported_Macros 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F10x_System_Exported_Functions 76 | * @{ 77 | */ 78 | 79 | extern void SystemInit(void); 80 | extern void SystemCoreClockUpdate(void); 81 | /** 82 | * @} 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /*__SYSTEM_STM32F10X_H */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 99 | -------------------------------------------------------------------------------- /libraries/stm32f10x_StdPeriph_Driver/inc/stm32f10x_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_CRC_H 25 | #define __STM32F10x_CRC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup CRC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup CRC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup CRC_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @defgroup CRC_Exported_Macros 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup CRC_Exported_Functions 67 | * @{ 68 | */ 69 | 70 | void CRC_ResetDR(void); 71 | uint32_t CRC_CalcCRC(uint32_t Data); 72 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 73 | uint32_t CRC_GetCRC(void); 74 | void CRC_SetIDRegister(uint8_t IDValue); 75 | uint8_t CRC_GetIDRegister(void); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* __STM32F10x_CRC_H */ 82 | /** 83 | * @} 84 | */ 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 95 | -------------------------------------------------------------------------------- /src/romdev.c: -------------------------------------------------------------------------------- 1 | #include "romdev.h" 2 | 3 | #include "syscall.h" 4 | #include "block.h" 5 | #include "path.h" 6 | 7 | 8 | void romdev_driver() { 9 | extern const char _sromdev; 10 | extern const char _eromdev; 11 | int self; 12 | int fd; 13 | struct block_request request; 14 | int cmd; 15 | size_t size; 16 | int pos; 17 | const char *request_start; 18 | const char *request_end; 19 | size_t request_len; 20 | 21 | /* Register path for device */ 22 | self = getpid() + 3; 23 | fd = path_register(ROMDEV_PATH); 24 | mknod(fd, 0, S_IFBLK); 25 | 26 | /* Service routine */ 27 | while (1) { 28 | if (read(self, &request, sizeof(request)) == sizeof(request)) { 29 | cmd = request.cmd; 30 | 31 | switch (cmd) { 32 | case BLOCK_CMD_READ: 33 | fd = request.fd; 34 | size = request.size; 35 | pos = request.pos; 36 | 37 | /* Check boundary */ 38 | request_start = &_sromdev + pos; 39 | if (request_start < &_sromdev) 40 | block_response(fd, NULL, -1); 41 | if (request_start > &_eromdev) 42 | request_start = &_eromdev; 43 | 44 | request_end = request_start + size; 45 | if (request_end > &_eromdev) 46 | request_end = &_eromdev; 47 | 48 | /* Response */ 49 | request_len = request_end - request_start; 50 | block_response(fd, (char *) request_start, request_len); 51 | break; 52 | 53 | case BLOCK_CMD_SEEK: 54 | fd = request.fd; 55 | size = request.size; 56 | pos = request.pos; 57 | 58 | if (pos == 0) { /* SEEK_SET */ 59 | request_len = size; 60 | } 61 | else if (pos < 0) { /* SEEK_END */ 62 | request_len = (&_eromdev - &_sromdev) + size; 63 | } 64 | else { /* SEEK_CUR */ 65 | request_len = pos + size; 66 | } 67 | lseek(fd, request_len, SEEK_SET); 68 | break; 69 | 70 | case BLOCK_CMD_WRITE: /* readonly */ 71 | default: 72 | block_response(fd, NULL, -1); 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/context_switch.s: -------------------------------------------------------------------------------- 1 | .syntax unified 2 | .word current_tcb 3 | 4 | .type USART2_IRQHandler, %function 5 | .global USART2_IRQHandler 6 | USART2_IRQHandler: 7 | push {lr} 8 | bl c_usart2_handler 9 | bl set_pendsv 10 | nop 11 | pop {lr} 12 | bx lr 13 | 14 | .type USART1_IRQHandler, %function 15 | .global USART1_IRQHandler 16 | USART1_IRQHandler: 17 | push {lr} 18 | bl c_usart1_handler 19 | bl set_pendsv 20 | nop 21 | pop {lr} 22 | bx lr 23 | 24 | .type SysTick_Handler, %function 25 | .global SysTick_Handler 26 | SysTick_Handler: 27 | push {lr} 28 | bl c_systick_handler 29 | bl set_pendsv 30 | nop 31 | pop {lr} 32 | bx lr 33 | 34 | .type PendSV_Handler, %function 35 | .global PendSV_Handler 36 | PendSV_Handler: 37 | cpsid i 38 | push {lr} 39 | bl trace_pendsv_switch_prev 40 | pop {lr} 41 | mrs r0, psp 42 | 43 | ldr r3, =current_tcb 44 | ldr r2, [r3] 45 | ldr r1, [r2] 46 | 47 | stmdb r0!, {r7} 48 | stmdb r0!, {r4-r11,ip} 49 | str r0, [r2] 50 | 51 | stmdb sp!, {r3, lr} 52 | bl context_switch 53 | ldmia sp!, {r3, lr} 54 | 55 | ldr r1, [r3] 56 | ldr r0, [r1] 57 | 58 | ldmia r0!, {r4-r11,ip} 59 | ldmia r0!, {r7} 60 | msr psp, r0 61 | push {lr} 62 | bl trace_pendsv_switch_now 63 | pop {lr} 64 | cpsie i 65 | bx lr 66 | 67 | .type SVC_Handler, %function 68 | .global SVC_Handler 69 | SVC_Handler: 70 | # push {lr} 71 | # bl trace_interrupt_in 72 | # pop {lr} 73 | push {lr} 74 | 75 | mrs r0, psp 76 | ldr r3, =current_tcb 77 | ldr r2, [r3] 78 | ldr r1, [r2] 79 | 80 | stmdb r0!, {r7} 81 | stmdb r0!, {r4-r11,ip} 82 | str r0, [r2] 83 | 84 | stmdb sp!, {r3, lr} 85 | bl syscall_handler 86 | ldmia sp!, {r3, lr} 87 | 88 | ldr r1, [r3] 89 | ldr r0, [r1] 90 | 91 | ldmia r0!, {r4-r11,ip} 92 | ldmia r0!, {r7} 93 | 94 | bl set_pendsv 95 | # bl trace_interrupt_out 96 | pop {lr} 97 | bx lr 98 | 99 | 100 | .type task_start, %function 101 | .global task_start 102 | task_start: 103 | /* save kernel state */ 104 | ldr r3, =current_tcb 105 | /* Use CurrentTCB to get the CurrentTCB address. */ 106 | ldr r1, [r3] 107 | /* The first item in CurrentTCB is the task top of stack. */ 108 | ldr r0, [r1] 109 | 110 | ldmia r0!, {r4-r11,lr} 111 | ldmia r0!, {r7} 112 | 113 | /* switch to process stack pointer */ 114 | msr psp, r0 115 | mov r0, #3 116 | msr control, r0 117 | isb 118 | bx lr 119 | -------------------------------------------------------------------------------- /include/pthread.h: -------------------------------------------------------------------------------- 1 | #ifndef PTHREAD_H 2 | #define PTHREAD_H 3 | #include "pthreadtypes.h" 4 | #include "erron.h" 5 | 6 | #define STATE_ILEGAL 0 7 | #define STATE_LEGAL 1 8 | 9 | #define PTHREAD_MUTEX_INITIALIZER {\ 10 | .data.lock = 0, \ 11 | .data.count = 0, \ 12 | .data.state = STATE_LEGAL \ 13 | } 14 | 15 | enum 16 | { 17 | PTHREAD_CREATE_JOINABLE, 18 | PTHREAD_CREATE_DETACHED 19 | }; 20 | 21 | 22 | enum 23 | { 24 | PTHREAD_MUTEX_DEFAULT, 25 | PTHREAD_MUTEX_ERRORCHECK, 26 | PTHREAD_MUTEX_NORMAL, 27 | PTHREAD_MUTEX_RECURSIVE 28 | }; 29 | 30 | /* Mutex types. */ 31 | enum 32 | { 33 | PTHREAD_MUTEX_TIMED_NP, 34 | PTHREAD_MUTEX_RECURSIVE_NP, 35 | PTHREAD_MUTEX_ERRORCHECK_NP, 36 | PTHREAD_MUTEX_ADAPTIVE_NP 37 | }; 38 | 39 | 40 | enum 41 | { 42 | PTHREAD_MUTEX_STALLED, 43 | PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED, 44 | PTHREAD_MUTEX_ROBUST, 45 | PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST 46 | }; 47 | 48 | /* Mutex protocols. */ 49 | enum 50 | { 51 | PTHREAD_PRIO_NONE, 52 | PTHREAD_PRIO_INHERIT, 53 | PTHREAD_PRIO_PROTECT 54 | }; 55 | 56 | int pthread_create(pthread_t *restrict thread, 57 | const pthread_attr_t *restrict attr, 58 | void *(*start_routine)(void*), 59 | void *restrict arg) __attribute__((nonnull (1, 3))); 60 | 61 | 62 | pthread_t pthread_self(); 63 | int pthread_equal(pthread_t, pthread_t) __attribute__((nonnull (1, 2))); 64 | void pthread_exit(void *value_ptr); 65 | int pthread_cancel(pthread_t thread); 66 | 67 | int pthread_attr_init(pthread_attr_t *attr); 68 | int pthread_attr_destroy(pthread_attr_t *attr); 69 | int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate); 70 | int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); 71 | 72 | int pthread_attr_getschedparam(const pthread_attr_t *restrict attr, 73 | struct sched_param *restrict param); 74 | int pthread_attr_setschedparam(pthread_attr_t *restrict attr, 75 | const struct sched_param *restrict param); 76 | 77 | int pthread_getschedparam(pthread_t thread, int *restrict policy, struct sched_param *restrict param); 78 | int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param); 79 | 80 | int pthread_join(pthread_t thread, void **value_ptr); 81 | int pthread_detach(pthread_t thread); 82 | 83 | int pthread_mutexattr_destroy(pthread_mutexattr_t *attr); 84 | int pthread_mutexattr_init(pthread_mutexattr_t *attr); 85 | 86 | 87 | int pthread_mutex_destroy(pthread_mutex_t *mutex); 88 | int pthread_mutex_init(pthread_mutex_t *restrict mutex, 89 | const pthread_mutexattr_t *restrict attr); 90 | 91 | int pthread_mutex_lock(pthread_mutex_t *mutex); 92 | int pthread_mutex_trylock(pthread_mutex_t *mutex); 93 | int pthread_mutex_unlock(pthread_mutex_t *mutex); 94 | 95 | 96 | #endif 97 | 98 | -------------------------------------------------------------------------------- /libraries/stm32f429_StdPeriph_Driver/inc/stm32f4xx_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_crc.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_CRC_H 31 | #define __STM32F4xx_CRC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup CRC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup CRC_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /* Exported macro ------------------------------------------------------------*/ 60 | /* Exported functions --------------------------------------------------------*/ 61 | 62 | void CRC_ResetDR(void); 63 | uint32_t CRC_CalcCRC(uint32_t Data); 64 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 65 | uint32_t CRC_GetCRC(void); 66 | void CRC_SetIDRegister(uint8_t IDValue); 67 | uint8_t CRC_GetIDRegister(void); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* __STM32F4xx_CRC_H */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 84 | -------------------------------------------------------------------------------- /libraries/CMSIS/CM4/DeviceSupport/ST/stm32f429/Include/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /** @addtogroup CMSIS 29 | * @{ 30 | */ 31 | 32 | /** @addtogroup stm32f4xx_system 33 | * @{ 34 | */ 35 | 36 | /** 37 | * @brief Define to prevent recursive inclusion 38 | */ 39 | #ifndef __SYSTEM_STM32F4XX_H 40 | #define __SYSTEM_STM32F4XX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** @addtogroup STM32F4xx_System_Includes 47 | * @{ 48 | */ 49 | 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @addtogroup STM32F4xx_System_Exported_types 56 | * @{ 57 | */ 58 | 59 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 60 | 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @addtogroup STM32F4xx_System_Exported_Constants 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @addtogroup STM32F4xx_System_Exported_Macros 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @addtogroup STM32F4xx_System_Exported_Functions 83 | * @{ 84 | */ 85 | 86 | extern void SystemInit(void); 87 | extern void SystemCoreClockUpdate(void); 88 | /** 89 | * @} 90 | */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /*__SYSTEM_STM32F4XX_H */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** 103 | * @} 104 | */ 105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 106 | -------------------------------------------------------------------------------- /src/malloc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "malloc.h" 3 | #include "kernel.h" 4 | #define MAX_HEAPS 256 5 | 6 | typedef long Align; 7 | 8 | union header { 9 | struct { 10 | union header *ptr; 11 | unsigned int size; 12 | } s; 13 | Align x; 14 | }; 15 | 16 | typedef union header Header; 17 | 18 | static unsigned char heaps[MAX_HEAPS]; 19 | static unsigned char *program_break = heaps; 20 | 21 | static Header base; /* empty list to get started */ 22 | static Header *freep = NULL; /* start of free list */ 23 | 24 | static void *sbrk(unsigned int nbytes) { 25 | if (program_break + nbytes >= heaps && 26 | program_break + nbytes < heaps + MAX_HEAPS) { 27 | unsigned char *previous_pb = program_break; 28 | program_break += nbytes; 29 | return (void *) previous_pb; 30 | } 31 | else { 32 | return (void *) -1; 33 | } 34 | } 35 | 36 | void *malloc(unsigned int nbytes) { 37 | Header *p, *prevp; 38 | unsigned int nunits; 39 | void *cp; 40 | 41 | nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; 42 | 43 | if ((prevp = freep) == NULL) { 44 | base.s.ptr = freep = prevp = &base; 45 | base.s.size = 0; 46 | } 47 | 48 | for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { 49 | if (p->s.size >= nunits) { 50 | if (p->s.size == nunits) { 51 | prevp->s.ptr = p->s.ptr; 52 | } 53 | else { 54 | p->s.size -= nunits; 55 | p += p->s.size; 56 | p->s.size = nunits; 57 | } 58 | freep = prevp; 59 | return (void *) (p + 1); 60 | } 61 | 62 | if (p == freep) { 63 | cp = sbrk(nunits * sizeof(Header)); 64 | if (cp == (void *) -1) { 65 | return NULL; 66 | } 67 | else { 68 | p = (Header *) cp; 69 | p->s.size = nunits; 70 | free((void *) (p + 1)); 71 | p = freep; 72 | } 73 | } 74 | } 75 | } 76 | 77 | void free(void *ap) { 78 | Header *bp, *p; 79 | bp = (Header *) ap - 1; 80 | 81 | for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) { 82 | if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 83 | break; 84 | } 85 | 86 | if (bp + bp->s.size == p->s.ptr) { 87 | bp->s.size += p->s.ptr->s.size; 88 | bp->s.ptr = p->s.ptr->s.ptr; 89 | } 90 | else { 91 | bp->s.ptr = p->s.ptr; 92 | } 93 | 94 | if (p + p->s.size == bp) { 95 | p->s.size += bp->s.size; 96 | p->s.ptr = bp->s.ptr; 97 | } 98 | else { 99 | p->s.ptr = bp; 100 | } 101 | 102 | freep = p; 103 | } 104 | -------------------------------------------------------------------------------- /include/RTOSConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef RTOS_CONFIG_H 2 | #define RTOS_CONFIG_H 3 | 4 | #define xPortPendSVHandler PendSV_Handler 5 | #define xPortSysTickHandler SysTick_Handler 6 | #define vPortSVCHandler SVC_Handler 7 | 8 | #define configUSE_PREEMPTION 1 9 | #define configUSE_IDLE_HOOK 1 10 | #define configUSE_TICK_HOOK 1 11 | #define configCPU_CLOCK_HZ ( ( unsigned long ) 180000000 ) 12 | #define configTICK_RATE_HZ ( ( portTickType ) 100 ) 13 | #define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) 14 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 ) 15 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 17 * 1024 ) ) 16 | #define configMAX_TASK_NAME_LEN ( 16 ) 17 | #define configUSE_TRACE_FACILITY 0 18 | #define configUSE_16_BIT_TICKS 0 19 | #define configIDLE_SHOULD_YIELD 1 20 | #define configUSE_MUTEXES 1 21 | 22 | /* Co-routine definitions. */ 23 | #define configUSE_CO_ROUTINES 0 24 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 25 | 26 | /* Set the following definitions to 1 to include the API function, or zero 27 | to exclude the API function. */ 28 | 29 | #define INCLUDE_vTaskPrioritySet 1 30 | #define INCLUDE_uxTaskPriorityGet 1 31 | #define INCLUDE_vTaskDelete 1 32 | #define INCLUDE_vTaskCleanUpResources 0 33 | #define INCLUDE_vTaskSuspend 1 34 | #define INCLUDE_vTaskDelayUntil 1 35 | #define INCLUDE_vTaskDelay 1 36 | 37 | /* Tracer functions */ 38 | #define traceTASK_SWITCHED_OUT my_switched_out_task 39 | void my_switched_out_task(); 40 | #define traceTASK_SWITCHED_IN my_switched_in_task 41 | void my_switched_in_task(); 42 | 43 | /* This is the raw value as per the Cortex-M3 NVIC. Values can be 255 44 | (lowest) to 0 (1?) (highest). */ 45 | #define configKERNEL_INTERRUPT_PRIORITY 127 //Needs to be below 240 (0xf0) to work with QEMU, since this is the priority mask used 46 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */ 47 | 48 | 49 | /* This is the value being used as per the ST library which permits 16 50 | priority values, 0 to 15. This must correspond to the 51 | configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest 52 | NVIC value of 255. */ 53 | #define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 54 | 55 | /* Types */ 56 | /* Type definitions. */ 57 | #define portCHAR char 58 | #define portFLOAT float 59 | #define portDOUBLE double 60 | #define portLONG long 61 | #define portSHORT short 62 | #define portSTACK_TYPE unsigned portLONG 63 | #define portBASE_TYPE long 64 | 65 | #if( configUSE_16_BIT_TICKS == 1 ) 66 | typedef unsigned portSHORT portTickType; 67 | #define portMAX_DELAY ( portTickType ) 0xffff 68 | #else 69 | typedef unsigned portLONG portTickType; 70 | #define portMAX_DELAY ( portTickType ) 0xffffffff 71 | #endif 72 | 73 | #endif /* RTOS_CONFIG_H */ 74 | -------------------------------------------------------------------------------- /src/task.c: -------------------------------------------------------------------------------- 1 | #include "task.h" 2 | #include "kconfig.h" 3 | #include "kernel.h" 4 | 5 | #include "syscall.h" 6 | 7 | #include "erron.h" 8 | #include 9 | #include 10 | #include 11 | #include "string.h" 12 | #include "task.h" 13 | #include "memory-pool.h" 14 | #include "path.h" 15 | #include "pipe.h" 16 | #include "fifo.h" 17 | #include "mqueue.h" 18 | #include "block.h" 19 | #include "romdev.h" 20 | #include "event-monitor.h" 21 | #include "romfs.h" 22 | #include 23 | #include "trace.h" 24 | 25 | /* System resources */ 26 | extern struct task_control_block tasks[TASK_LIMIT]; 27 | extern unsigned int stacks[TASK_LIMIT][STACK_SIZE]; 28 | extern struct list ready_list[PRIORITY_LIMIT + 1]; /* [0 ... 39] */ 29 | extern size_t task_count; 30 | extern struct task_control_block *current_tcb; 31 | extern struct event_monitor event_monitor; 32 | 33 | int prv_priority = PRIORITY_DEFAULT; 34 | 35 | unsigned int *init_task(unsigned int *stack, void (*start)()) { 36 | stack += STACK_SIZE - 18; /* End of stack, minus what we're about to push */ 37 | stack[8] = (unsigned int) start; 38 | stack[16] = (unsigned int) start; 39 | stack[17] = (unsigned int) 0x01000000; 40 | return stack; 41 | } 42 | 43 | static inline int task_search_empty() { 44 | int i; 45 | for (i = 0; i < TASK_LIMIT; i++) { 46 | if (tasks[i].inuse == 0) { 47 | break; 48 | } 49 | } 50 | return i; 51 | } 52 | 53 | /* 54 | * TODO 55 | * Arguments passed to thread, pthread_create need too 56 | */ 57 | struct task_control_block *task_create(int priority, void *func, void *arg) { 58 | int task_pid; 59 | if (task_count == TASK_LIMIT || 60 | (task_pid = task_search_empty()) == TASK_LIMIT) { 61 | return NULL; 62 | } 63 | tasks[task_pid].stack = (void *) init_task(stacks[task_pid], func); 64 | tasks[task_pid].pid = task_pid; 65 | tasks[task_pid].priority = priority; 66 | tasks[task_pid].inuse = 1; 67 | list_init(&tasks[task_pid].list); 68 | list_push(&ready_list[tasks[task_pid].priority], &tasks[task_pid].list); 69 | task_count++; 70 | #ifdef TRACE 71 | trace_task_create(&tasks[task_pid], str, priority); 72 | #endif 73 | 74 | return &tasks[task_pid]; 75 | } 76 | 77 | 78 | /* 79 | * FIXME 80 | * Is it better to put task_kill and task_block 81 | * in the kernel level(call by syscall)? 82 | * (because its uses kernel level API(monitor)) 83 | */ 84 | 85 | int task_kill(int pid) { 86 | if (!tasks[pid].inuse) 87 | return EINVAL; 88 | _disable_irq(); 89 | list_remove(&tasks[pid].list); 90 | /* Never context switch here */ 91 | tasks[pid].inuse = 0; 92 | --task_count; 93 | event_monitor_release(&event_monitor, TASK_EVENT(pid)); 94 | _enable_irq(); 95 | 96 | return 0; 97 | } 98 | 99 | void task_exit(void *ptr) { 100 | task_kill(current_tcb->pid); 101 | while (1) 102 | ; 103 | } 104 | -------------------------------------------------------------------------------- /libraries/stm32f429_StdPeriph_Driver/Common/fonts.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file fonts.h 4 | * @author MCD Application Team 5 | * @version V5.0.2 6 | * @date 05-March-2012 7 | * @brief Header for fonts.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __FONTS_H 30 | #define __FONTS_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include 38 | 39 | /** @addtogroup Utilities 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup STM32_EVAL 44 | * @{ 45 | */ 46 | 47 | /** @addtogroup Common 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup FONTS 52 | * @{ 53 | */ 54 | 55 | /** @defgroup FONTS_Exported_Types 56 | * @{ 57 | */ 58 | typedef struct _tFont 59 | { 60 | const uint16_t *table; 61 | uint16_t Width; 62 | uint16_t Height; 63 | 64 | } sFONT; 65 | 66 | extern sFONT Font16x24; 67 | extern sFONT Font12x12; 68 | extern sFONT Font8x12; 69 | extern sFONT Font8x8; 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup FONTS_Exported_Constants 76 | * @{ 77 | */ 78 | #define LINE(x) ((x) * (((sFONT *)LCD_GetFont())->Height)) 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup FONTS_Exported_Macros 85 | * @{ 86 | */ 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @defgroup FONTS_Exported_Functions 92 | * @{ 93 | */ 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __FONTS_H */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 125 | -------------------------------------------------------------------------------- /libraries/stm32f10x_StdPeriph_Driver/inc/stm32f10x_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_wwdg.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the WWDG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_WWDG_H 25 | #define __STM32F10x_WWDG_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup WWDG 39 | * @{ 40 | */ 41 | 42 | /** @defgroup WWDG_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup WWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup WWDG_Prescaler 55 | * @{ 56 | */ 57 | 58 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 59 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 60 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 61 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 62 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 63 | ((PRESCALER) == WWDG_Prescaler_2) || \ 64 | ((PRESCALER) == WWDG_Prescaler_4) || \ 65 | ((PRESCALER) == WWDG_Prescaler_8)) 66 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 67 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @defgroup WWDG_Exported_Macros 78 | * @{ 79 | */ 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup WWDG_Exported_Functions 85 | * @{ 86 | */ 87 | 88 | void WWDG_DeInit(void); 89 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 90 | void WWDG_SetWindowValue(uint8_t WindowValue); 91 | void WWDG_EnableIT(void); 92 | void WWDG_SetCounter(uint8_t Counter); 93 | void WWDG_Enable(uint8_t Counter); 94 | FlagStatus WWDG_GetFlagStatus(void); 95 | void WWDG_ClearFlag(void); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __STM32F10x_WWDG_H */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 116 | -------------------------------------------------------------------------------- /platform/stm32f10x/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | #include "stm32f10x_usart.h" 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /libraries/stm32f429_StdPeriph_Driver/Common/lcd_log_conf_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file lcd_log_conf_template.h 4 | * @author MCD Application Team 5 | * @version V5.0.2 6 | * @date 05-March-2012 7 | * @brief lcd_log configuration template file. 8 | * This file should be copied to the application folder and modified 9 | * as follows: 10 | * - Rename it to 'lcd_log_conf.h'. 11 | * - Update the name of the LCD header file depending on the EVAL board 12 | * you are using (see line32 below). 13 | ****************************************************************************** 14 | * @attention 15 | * 16 | *

© COPYRIGHT 2012 STMicroelectronics

17 | * 18 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 19 | * You may not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at: 21 | * 22 | * http://www.st.com/software_license_agreement_liberty_v2 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an "AS IS" BASIS, 26 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | * 30 | ****************************************************************************** 31 | */ 32 | 33 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | #ifndef __LCD_LOG_CONF_H__ 35 | #define __LCD_LOG_CONF_H__ 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32xxx_eval_lcd.h" /* replace 'stm32xxx' with your EVAL board name, ex: stm3210c_eval_lcd.h */ 39 | #include 40 | 41 | /** @addtogroup LCD_LOG 42 | * @{ 43 | */ 44 | 45 | /** @defgroup LCD_LOG 46 | * @brief This file is the 47 | * @{ 48 | */ 49 | 50 | 51 | /** @defgroup LCD_LOG_CONF_Exported_Defines 52 | * @{ 53 | */ 54 | /* Comment the line below to disable the scroll back and forward features */ 55 | #define LCD_SCROLL_ENABLED 56 | 57 | /* Define the LCD default text color */ 58 | #define LCD_LOG_DEFAULT_COLOR LCD_COLOR_WHITE 59 | 60 | /* Define the display window settings */ 61 | #define YWINDOW_MIN 3 62 | #define YWINDOW_SIZE 12 63 | #define XWINDOW_MAX 50 64 | 65 | /* Define the cache depth */ 66 | #define CACHE_SIZE 50 67 | 68 | /** @defgroup LCD_LOG_CONF_Exported_TypesDefinitions 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | 77 | /** @defgroup LCD_LOG_Exported_Macros 78 | * @{ 79 | */ 80 | 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup LCD_LOG_CONF_Exported_Variables 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup LCD_LOG_CONF_Exported_FunctionsPrototype 95 | * @{ 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | 103 | #endif /* __LCD_LOG_H__ */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 114 | -------------------------------------------------------------------------------- /include/signal.h: -------------------------------------------------------------------------------- 1 | #ifndef SIGNAL_H 2 | #define SIGNAL_H 3 | 4 | #include "pthreadtypes.h" 5 | 6 | typedef unsigned int pid_t; 7 | 8 | typedef void (*sighandler_t)(int); 9 | typedef volatile int sig_atomic_t; 10 | typedef int sigset_t; 11 | 12 | #define SIGSET 0 13 | #define SIGDFL 1 14 | #define SIGRAISE 2 15 | #define SIGIGN 3 16 | 17 | #define SIG_DFL ((void(*)(int))1) 18 | #define SIG_ERR ((void(*)(int))2) 19 | #define SIG_HOLD ((void(*)(int))3) 20 | #define SIG_IGN ((void(*)(int))4) 21 | 22 | #define SIGABRT 0 23 | #define SIGALRM 1 24 | #define SIGBUS 2 25 | #define SIGCHLD 3 26 | #define SIGCONT 4 27 | #define SIGFPE 5 28 | #define SIGHUP 6 29 | #define SIGILL 7 30 | #define SIGINT 8 31 | #define SIGKILL 9 32 | #define SIGPIPE 10 33 | #define SIGQUIT 11 34 | #define SIGSEGV 12 35 | #define SIGSTOP 13 36 | #define SIGTERM 14 37 | #define SIGTSTP 15 38 | #define SIGTTIN 16 39 | #define SIGTTOU 17 40 | #define SIGUSR1 18 41 | #define SIGUSR2 19 42 | #define SIGTRAP 20 43 | #define SIGURG 21 44 | #define SIGXCPU 22 45 | #define SIGXFSZ 23 46 | 47 | #define SIGNUM 24 48 | 49 | #define SIG_BLOCK 0 50 | #define SIG_UNBLOCK 1 51 | #define SIG_SETMASK 2 52 | 53 | union sigval { 54 | int sival_int; /* Integer signal value */ 55 | void* sival_ptr; /* Pointer signal value */ 56 | }; 57 | 58 | 59 | #define SIGEV_NONE 0 60 | #define SIGEV_SIGNAL 1 61 | #define SIGEV_THREAD 2 62 | 63 | struct sigevent { 64 | int sigev_notify; /* Notification type */ 65 | int sigev_signo; /* Signal number */ 66 | union sigval sigev_value; /* Signal value */ 67 | void (*signev_notify_function)(union sigval); /* Notification function */ 68 | pthread_attr_t* sigev_notify_attributes; /* Notification function */ 69 | }; 70 | 71 | typedef struct { 72 | int si_signo; 73 | int si_code; 74 | int si_errno; 75 | pid_t si_pid; 76 | void* si_addr; 77 | int si_status; 78 | union sigval si_value; 79 | } siginfo_t; 80 | 81 | struct sigaction { 82 | union { 83 | void (*sa_handler) (int); 84 | void (*sa_sigaction) (int, siginfo_t *, void *); 85 | } sa_u; 86 | sigset_t sa_mask; 87 | int sa_flags; 88 | }; 89 | 90 | void (*signal(int, void (*)(int)))(int); 91 | 92 | 93 | 94 | int kill(pid_t, int); 95 | int killpg(pid_t, int); 96 | void psiginfo(const siginfo_t *, const char *); 97 | void psignal(int, const char *); 98 | int pthread_kill(pthread_t, int); 99 | int pthread_sigmask(int, const sigset_t *restrict, 100 | sigset_t *restrict); 101 | int raise(int); 102 | int sigaction(int, const struct sigaction *restrict, 103 | struct sigaction *restrict); 104 | int sigaddset(sigset_t *, int); 105 | //int sigaltstack(const stack_t *restrict, stack_t *restrict); 106 | int sigdelset(sigset_t *, int); 107 | int sigemptyset(sigset_t *); 108 | int sigfillset(sigset_t *); 109 | int sighold(int); 110 | int sigignore(int); 111 | int siginterrupt(int, int); 112 | int sigismember(const sigset_t *, int); 113 | int sigpause(int); 114 | int sigpending(sigset_t *); 115 | int sigprocmask(int, const sigset_t *restrict, sigset_t *restrict); 116 | int sigqueue(pid_t, int, const union sigval); 117 | int sigrelse(int); 118 | void (*sigset(int, void (*)(int)))(int); 119 | int sigsuspend(const sigset_t *); 120 | //int sigtimedwait(const sigset_t *restrict, siginfo_t *restrict, 121 | // const struct timespec *restrict); 122 | int sigwait(const sigset_t *restrict, int *restrict); 123 | int sigwaitinfo(const sigset_t *restrict, siginfo_t *restrict); 124 | 125 | 126 | #endif 127 | 128 | 129 | -------------------------------------------------------------------------------- /src/fifo.c: -------------------------------------------------------------------------------- 1 | #include "fifo.h" 2 | 3 | #include "pipe.h" 4 | #include "utils.h" 5 | 6 | 7 | 8 | static struct file_operations fifo_ops = { 9 | .readable = fifo_readable, 10 | .writable = fifo_writable, 11 | .read = fifo_read, 12 | .write = fifo_write, 13 | .lseekable = NULL, 14 | .lseek = NULL, 15 | }; 16 | 17 | int mkfifo(const char *pathname, int mode) { 18 | mkfile(pathname, mode, S_IFIFO); 19 | return 0; 20 | } 21 | 22 | int fifo_init(int fd, int driver_pid, struct file *files[], 23 | struct memory_pool *memory_pool, struct event_monitor *monitor) { 24 | struct pipe_ringbuffer *pipe; 25 | 26 | pipe = memory_pool_alloc(memory_pool, sizeof(struct pipe_ringbuffer)); 27 | 28 | if (!pipe) 29 | return -1; 30 | 31 | pipe->start = 0; 32 | pipe->end = 0; 33 | pipe->file.ops = &fifo_ops; 34 | files[fd] = &pipe->file; 35 | 36 | pipe->read_event = event_monitor_find_free(monitor); 37 | event_monitor_register(monitor, pipe->read_event, pipe_read_release, 38 | files[fd]); 39 | 40 | pipe->write_event = event_monitor_find_free(monitor); 41 | event_monitor_register(monitor, pipe->write_event, pipe_write_release, 42 | files[fd]); 43 | return 0; 44 | } 45 | 46 | int fifo_readable(struct file *file, struct file_request *request, 47 | struct event_monitor *monitor) { 48 | /* Trying to read too much */ 49 | if (request->size > PIPE_BUF) { 50 | return FILE_ACCESS_ERROR; 51 | } 52 | 53 | struct pipe_ringbuffer *pipe = 54 | container_of(file, struct pipe_ringbuffer, file); 55 | 56 | if ((size_t) PIPE_LEN(*pipe) < request->size) { 57 | /* Trying to read more than there is: block */ 58 | event_monitor_block(monitor, pipe->read_event, request->task); 59 | return FILE_ACCESS_BLOCK; 60 | } 61 | return FILE_ACCESS_ACCEPT; 62 | } 63 | 64 | int fifo_writable(struct file *file, struct file_request *request, 65 | struct event_monitor *monitor) { 66 | struct pipe_ringbuffer *pipe = 67 | container_of(file, struct pipe_ringbuffer, file); 68 | 69 | /* If the write would be non-atomic */ 70 | if (request->size > PIPE_BUF) { 71 | return FILE_ACCESS_ERROR; 72 | } 73 | /* Preserve 1 byte to distiguish empty or full */ 74 | if ((size_t) PIPE_BUF - PIPE_LEN(*pipe) - 1 < request->size) { 75 | /* Trying to write more than we have space for: block */ 76 | event_monitor_block(monitor, pipe->write_event, request->task); 77 | return FILE_ACCESS_BLOCK; 78 | } 79 | return FILE_ACCESS_ACCEPT; 80 | } 81 | 82 | int fifo_read(struct file *file, struct file_request *request, 83 | struct event_monitor *monitor) { 84 | size_t i; 85 | struct pipe_ringbuffer *pipe = 86 | container_of(file, struct pipe_ringbuffer, file); 87 | 88 | /* Copy data into buf */ 89 | for (i = 0; i < request->size; i++) { 90 | PIPE_POP(*pipe, request->buf[i]); 91 | } 92 | 93 | /* Prepared to write */ 94 | event_monitor_release(monitor, pipe->write_event); 95 | return request->size; 96 | } 97 | 98 | int fifo_write(struct file *file, struct file_request *request, 99 | struct event_monitor *monitor) { 100 | size_t i; 101 | struct pipe_ringbuffer *pipe = 102 | container_of(file, struct pipe_ringbuffer, file); 103 | 104 | /* Copy data into pipe */ 105 | for (i = 0; i < request->size; i++) 106 | PIPE_PUSH(*pipe, request->buf[i]); 107 | 108 | /* Prepared to read */ 109 | event_monitor_release(monitor, pipe->read_event); 110 | return request->size; 111 | } 112 | -------------------------------------------------------------------------------- /libraries/CMSIS/CM4/CoreSupport/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2013 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 17. January 2013 5 | * $Revision: V1.4.1 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len16 = { 50 | 16, twiddleCoef_16, armBitRevIndexTable16, ARMBITREVINDEXTABLE__16_TABLE_LENGTH 51 | }; 52 | 53 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len32 = { 54 | 32, twiddleCoef_32, armBitRevIndexTable32, ARMBITREVINDEXTABLE__32_TABLE_LENGTH 55 | }; 56 | 57 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len64 = { 58 | 64, twiddleCoef_64, armBitRevIndexTable64, ARMBITREVINDEXTABLE__64_TABLE_LENGTH 59 | }; 60 | 61 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len128 = { 62 | 128, twiddleCoef_128, armBitRevIndexTable128, ARMBITREVINDEXTABLE_128_TABLE_LENGTH 63 | }; 64 | 65 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len256 = { 66 | 256, twiddleCoef_256, armBitRevIndexTable256, ARMBITREVINDEXTABLE_256_TABLE_LENGTH 67 | }; 68 | 69 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len512 = { 70 | 512, twiddleCoef_512, armBitRevIndexTable512, ARMBITREVINDEXTABLE_512_TABLE_LENGTH 71 | }; 72 | 73 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024 = { 74 | 1024, twiddleCoef_1024, armBitRevIndexTable1024, ARMBITREVINDEXTABLE1024_TABLE_LENGTH 75 | }; 76 | 77 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048 = { 78 | 2048, twiddleCoef_2048, armBitRevIndexTable2048, ARMBITREVINDEXTABLE2048_TABLE_LENGTH 79 | }; 80 | 81 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096 = { 82 | 4096, twiddleCoef_4096, armBitRevIndexTable4096, ARMBITREVINDEXTABLE4096_TABLE_LENGTH 83 | }; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /libraries/stm32f10x_StdPeriph_Driver/src/stm32f10x_crc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the CRC firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_crc.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup CRC 30 | * @brief CRC driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup CRC_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup CRC_Private_Defines 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup CRC_Private_Macros 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @defgroup CRC_Private_Variables 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup CRC_Private_FunctionPrototypes 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup CRC_Private_Functions 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @brief Resets the CRC Data register (DR). 80 | * @param None 81 | * @retval None 82 | */ 83 | void CRC_ResetDR(void) 84 | { 85 | /* Reset CRC generator */ 86 | CRC->CR = CRC_CR_RESET; 87 | } 88 | 89 | /** 90 | * @brief Computes the 32-bit CRC of a given data word(32-bit). 91 | * @param Data: data word(32-bit) to compute its CRC 92 | * @retval 32-bit CRC 93 | */ 94 | uint32_t CRC_CalcCRC(uint32_t Data) 95 | { 96 | CRC->DR = Data; 97 | 98 | return (CRC->DR); 99 | } 100 | 101 | /** 102 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). 103 | * @param pBuffer: pointer to the buffer containing the data to be computed 104 | * @param BufferLength: length of the buffer to be computed 105 | * @retval 32-bit CRC 106 | */ 107 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) 108 | { 109 | uint32_t index = 0; 110 | 111 | for(index = 0; index < BufferLength; index++) 112 | { 113 | CRC->DR = pBuffer[index]; 114 | } 115 | return (CRC->DR); 116 | } 117 | 118 | /** 119 | * @brief Returns the current CRC value. 120 | * @param None 121 | * @retval 32-bit CRC 122 | */ 123 | uint32_t CRC_GetCRC(void) 124 | { 125 | return (CRC->DR); 126 | } 127 | 128 | /** 129 | * @brief Stores a 8-bit data in the Independent Data(ID) register. 130 | * @param IDValue: 8-bit value to be stored in the ID register 131 | * @retval None 132 | */ 133 | void CRC_SetIDRegister(uint8_t IDValue) 134 | { 135 | CRC->IDR = IDValue; 136 | } 137 | 138 | /** 139 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register 140 | * @param None 141 | * @retval 8-bit value of the ID register 142 | */ 143 | uint8_t CRC_GetIDRegister(void) 144 | { 145 | return (CRC->IDR); 146 | } 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 161 | -------------------------------------------------------------------------------- /libraries/stm32f429_StdPeriph_Driver/inc/stm32f4xx_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_wwdg.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the WWDG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_WWDG_H 31 | #define __STM32F4xx_WWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup WWDG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup WWDG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup WWDG_Prescaler 56 | * @{ 57 | */ 58 | 59 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 60 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 61 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 62 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 63 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 64 | ((PRESCALER) == WWDG_Prescaler_2) || \ 65 | ((PRESCALER) == WWDG_Prescaler_4) || \ 66 | ((PRESCALER) == WWDG_Prescaler_8)) 67 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 68 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /* Exported macro ------------------------------------------------------------*/ 79 | /* Exported functions --------------------------------------------------------*/ 80 | 81 | /* Function used to set the WWDG configuration to the default reset state ****/ 82 | void WWDG_DeInit(void); 83 | 84 | /* Prescaler, Refresh window and Counter configuration functions **************/ 85 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 86 | void WWDG_SetWindowValue(uint8_t WindowValue); 87 | void WWDG_EnableIT(void); 88 | void WWDG_SetCounter(uint8_t Counter); 89 | 90 | /* WWDG activation function ***************************************************/ 91 | void WWDG_Enable(uint8_t Counter); 92 | 93 | /* Interrupts and flags management functions **********************************/ 94 | FlagStatus WWDG_GetFlagStatus(void); 95 | void WWDG_ClearFlag(void); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __STM32F4xx_WWDG_H */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 112 | -------------------------------------------------------------------------------- /src/mqueue.c: -------------------------------------------------------------------------------- 1 | #include "mqueue.h" 2 | 3 | #include 4 | #include "utils.h" 5 | #include "pipe.h" 6 | 7 | 8 | 9 | static struct file_operations mq_ops = { 10 | .readable = mq_readable, 11 | .writable = mq_writable, 12 | .read = mq_read, 13 | .write = mq_write, 14 | .lseekable = NULL, 15 | .lseek = NULL, 16 | }; 17 | 18 | int mq_open(const char *name, int oflag) { 19 | if (oflag & O_CREAT) 20 | mkfile(name, 0, S_IMSGQ); 21 | return open(name, 0); 22 | } 23 | 24 | int mq_init(int fd, int driver_pid, struct file *files[], 25 | struct memory_pool *memory_pool, struct event_monitor *monitor) { 26 | struct pipe_ringbuffer *pipe; 27 | 28 | pipe = memory_pool_alloc(memory_pool, sizeof(struct pipe_ringbuffer)); 29 | 30 | if (!pipe) 31 | return -1; 32 | 33 | pipe->start = 0; 34 | pipe->end = 0; 35 | pipe->file.ops = &mq_ops; 36 | files[fd] = &pipe->file; 37 | 38 | pipe->read_event = event_monitor_find_free(monitor); 39 | event_monitor_register(monitor, pipe->read_event, pipe_read_release, 40 | files[fd]); 41 | 42 | pipe->write_event = event_monitor_find_free(monitor); 43 | event_monitor_register(monitor, pipe->write_event, pipe_write_release, 44 | files[fd]); 45 | return 0; 46 | } 47 | 48 | int mq_readable(struct file *file, struct file_request *request, 49 | struct event_monitor *monitor) { 50 | size_t msg_len; 51 | 52 | struct pipe_ringbuffer *pipe = 53 | container_of(file, struct pipe_ringbuffer, file); 54 | 55 | /* Trying to read too much */ 56 | if ((size_t) PIPE_LEN(*pipe) < sizeof(size_t)) { 57 | /* Nothing to read */ 58 | event_monitor_block(monitor, pipe->read_event, request->task); 59 | return FILE_ACCESS_BLOCK; 60 | } 61 | 62 | PIPE_PEEK(*pipe, msg_len, 4); 63 | 64 | if (msg_len > request->size) { 65 | /* Trying to read more than buffer size */ 66 | return FILE_ACCESS_ERROR; 67 | } 68 | return FILE_ACCESS_ACCEPT; 69 | } 70 | 71 | int mq_writable(struct file *file, struct file_request *request, 72 | struct event_monitor *monitor) { 73 | size_t total_len = sizeof(size_t) + request->size; 74 | struct pipe_ringbuffer *pipe = 75 | container_of(file, struct pipe_ringbuffer, file); 76 | 77 | /* If the write would be non-atomic */ 78 | if (total_len > PIPE_BUF) { 79 | return FILE_ACCESS_ERROR; 80 | } 81 | /* Preserve 1 byte to distiguish empty or full */ 82 | if ((size_t) PIPE_BUF - PIPE_LEN(*pipe) - 1 < total_len) { 83 | /* Trying to write more than we have space for: block */ 84 | event_monitor_block(monitor, pipe->write_event, request->task); 85 | return FILE_ACCESS_BLOCK; 86 | } 87 | return FILE_ACCESS_ACCEPT; 88 | } 89 | 90 | int mq_read(struct file *file, struct file_request *request, 91 | struct event_monitor *monitor) { 92 | size_t msg_len; 93 | size_t i; 94 | struct pipe_ringbuffer *pipe = 95 | container_of(file, struct pipe_ringbuffer, file); 96 | 97 | /* Get length */ 98 | for (i = 0; i < 4; i++) { 99 | PIPE_POP(*pipe, *(((char *) &msg_len) + i)); 100 | } 101 | /* Copy data into buf */ 102 | for (i = 0; i < msg_len; i++) { 103 | PIPE_POP(*pipe, request->buf[i]); 104 | } 105 | 106 | /* Prepared to write */ 107 | event_monitor_release(monitor, pipe->write_event); 108 | return msg_len; 109 | } 110 | 111 | int mq_write(struct file *file, struct file_request *request, 112 | struct event_monitor *monitor) { 113 | size_t i; 114 | struct pipe_ringbuffer *pipe = 115 | container_of(file, struct pipe_ringbuffer, file); 116 | 117 | /* Copy count into pipe */ 118 | for (i = 0; i < sizeof(size_t); i++) 119 | PIPE_PUSH(*pipe, *(((char *) &request->size) + i)); 120 | /* Copy data into pipe */ 121 | for (i = 0; i < request->size; i++) 122 | PIPE_PUSH(*pipe, request->buf[i]); 123 | 124 | /* Prepared to read */ 125 | event_monitor_release(monitor, pipe->read_event); 126 | return request->size; 127 | } 128 | -------------------------------------------------------------------------------- /libraries/stm32f10x_StdPeriph_Driver/inc/stm32f10x_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the DBGMCU 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_DBGMCU_H 25 | #define __STM32F10x_DBGMCU_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup DBGMCU 39 | * @{ 40 | */ 41 | 42 | /** @defgroup DBGMCU_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup DBGMCU_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 55 | #define DBGMCU_STOP ((uint32_t)0x00000002) 56 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 57 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00000100) 58 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000200) 59 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000400) 60 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000800) 61 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00001000) 62 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00002000) 63 | #define DBGMCU_CAN1_STOP ((uint32_t)0x00004000) 64 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00008000) 65 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00010000) 66 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00020000) 67 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00040000) 68 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00080000) 69 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00100000) 70 | #define DBGMCU_CAN2_STOP ((uint32_t)0x00200000) 71 | #define DBGMCU_TIM15_STOP ((uint32_t)0x00400000) 72 | #define DBGMCU_TIM16_STOP ((uint32_t)0x00800000) 73 | #define DBGMCU_TIM17_STOP ((uint32_t)0x01000000) 74 | #define DBGMCU_TIM12_STOP ((uint32_t)0x02000000) 75 | #define DBGMCU_TIM13_STOP ((uint32_t)0x04000000) 76 | #define DBGMCU_TIM14_STOP ((uint32_t)0x08000000) 77 | #define DBGMCU_TIM9_STOP ((uint32_t)0x10000000) 78 | #define DBGMCU_TIM10_STOP ((uint32_t)0x20000000) 79 | #define DBGMCU_TIM11_STOP ((uint32_t)0x40000000) 80 | 81 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0x800000F8) == 0x00) && ((PERIPH) != 0x00)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup DBGMCU_Exported_Macros 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup DBGMCU_Exported_Functions 95 | * @{ 96 | */ 97 | 98 | uint32_t DBGMCU_GetREVID(void); 99 | uint32_t DBGMCU_GetDEVID(void); 100 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif /* __STM32F10x_DBGMCU_H */ 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 120 | -------------------------------------------------------------------------------- /libraries/stm32f429_StdPeriph_Driver/src/stm32f4xx_crc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_crc.c 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file provides all the CRC firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx_crc.h" 30 | 31 | /** @addtogroup STM32F4xx_StdPeriph_Driver 32 | * @{ 33 | */ 34 | 35 | /** @defgroup CRC 36 | * @brief CRC driver modules 37 | * @{ 38 | */ 39 | 40 | /* Private typedef -----------------------------------------------------------*/ 41 | /* Private define ------------------------------------------------------------*/ 42 | /* Private macro -------------------------------------------------------------*/ 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* Private function prototypes -----------------------------------------------*/ 45 | /* Private functions ---------------------------------------------------------*/ 46 | 47 | /** @defgroup CRC_Private_Functions 48 | * @{ 49 | */ 50 | 51 | /** 52 | * @brief Resets the CRC Data register (DR). 53 | * @param None 54 | * @retval None 55 | */ 56 | void CRC_ResetDR(void) 57 | { 58 | /* Reset CRC generator */ 59 | CRC->CR = CRC_CR_RESET; 60 | } 61 | 62 | /** 63 | * @brief Computes the 32-bit CRC of a given data word(32-bit). 64 | * @param Data: data word(32-bit) to compute its CRC 65 | * @retval 32-bit CRC 66 | */ 67 | uint32_t CRC_CalcCRC(uint32_t Data) 68 | { 69 | CRC->DR = Data; 70 | 71 | return (CRC->DR); 72 | } 73 | 74 | /** 75 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). 76 | * @param pBuffer: pointer to the buffer containing the data to be computed 77 | * @param BufferLength: length of the buffer to be computed 78 | * @retval 32-bit CRC 79 | */ 80 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) 81 | { 82 | uint32_t index = 0; 83 | 84 | for(index = 0; index < BufferLength; index++) 85 | { 86 | CRC->DR = pBuffer[index]; 87 | } 88 | return (CRC->DR); 89 | } 90 | 91 | /** 92 | * @brief Returns the current CRC value. 93 | * @param None 94 | * @retval 32-bit CRC 95 | */ 96 | uint32_t CRC_GetCRC(void) 97 | { 98 | return (CRC->DR); 99 | } 100 | 101 | /** 102 | * @brief Stores a 8-bit data in the Independent Data(ID) register. 103 | * @param IDValue: 8-bit value to be stored in the ID register 104 | * @retval None 105 | */ 106 | void CRC_SetIDRegister(uint8_t IDValue) 107 | { 108 | CRC->IDR = IDValue; 109 | } 110 | 111 | /** 112 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register 113 | * @param None 114 | * @retval 8-bit value of the ID register 115 | */ 116 | uint8_t CRC_GetIDRegister(void) 117 | { 118 | return (CRC->IDR); 119 | } 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | /** 130 | * @} 131 | */ 132 | 133 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 134 | -------------------------------------------------------------------------------- /libraries/stm32f10x_StdPeriph_Driver/inc/stm32f10x_rtc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_rtc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the RTC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_RTC_H 25 | #define __STM32F10x_RTC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup RTC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup RTC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup RTC_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup RTC_interrupts_define 55 | * @{ 56 | */ 57 | 58 | #define RTC_IT_OW ((uint16_t)0x0004) /*!< Overflow interrupt */ 59 | #define RTC_IT_ALR ((uint16_t)0x0002) /*!< Alarm interrupt */ 60 | #define RTC_IT_SEC ((uint16_t)0x0001) /*!< Second interrupt */ 61 | #define IS_RTC_IT(IT) ((((IT) & (uint16_t)0xFFF8) == 0x00) && ((IT) != 0x00)) 62 | #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_OW) || ((IT) == RTC_IT_ALR) || \ 63 | ((IT) == RTC_IT_SEC)) 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup RTC_interrupts_flags 69 | * @{ 70 | */ 71 | 72 | #define RTC_FLAG_RTOFF ((uint16_t)0x0020) /*!< RTC Operation OFF flag */ 73 | #define RTC_FLAG_RSF ((uint16_t)0x0008) /*!< Registers Synchronized flag */ 74 | #define RTC_FLAG_OW ((uint16_t)0x0004) /*!< Overflow flag */ 75 | #define RTC_FLAG_ALR ((uint16_t)0x0002) /*!< Alarm flag */ 76 | #define RTC_FLAG_SEC ((uint16_t)0x0001) /*!< Second flag */ 77 | #define IS_RTC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFF0) == 0x00) && ((FLAG) != 0x00)) 78 | #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_RTOFF) || ((FLAG) == RTC_FLAG_RSF) || \ 79 | ((FLAG) == RTC_FLAG_OW) || ((FLAG) == RTC_FLAG_ALR) || \ 80 | ((FLAG) == RTC_FLAG_SEC)) 81 | #define IS_RTC_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFFFF) 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @defgroup RTC_Exported_Macros 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @defgroup RTC_Exported_Functions 100 | * @{ 101 | */ 102 | 103 | void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState); 104 | void RTC_EnterConfigMode(void); 105 | void RTC_ExitConfigMode(void); 106 | uint32_t RTC_GetCounter(void); 107 | void RTC_SetCounter(uint32_t CounterValue); 108 | void RTC_SetPrescaler(uint32_t PrescalerValue); 109 | void RTC_SetAlarm(uint32_t AlarmValue); 110 | uint32_t RTC_GetDivider(void); 111 | void RTC_WaitForLastTask(void); 112 | void RTC_WaitForSynchro(void); 113 | FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG); 114 | void RTC_ClearFlag(uint16_t RTC_FLAG); 115 | ITStatus RTC_GetITStatus(uint16_t RTC_IT); 116 | void RTC_ClearITPendingBit(uint16_t RTC_IT); 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* __STM32F10x_RTC_H */ 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 136 | -------------------------------------------------------------------------------- /libraries/stm32f10x_StdPeriph_Driver/inc/stm32f10x_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_iwdg.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_IWDG_H 25 | #define __STM32F10x_IWDG_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup IWDG 39 | * @{ 40 | */ 41 | 42 | /** @defgroup IWDG_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup IWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup IWDG_WriteAccess 55 | * @{ 56 | */ 57 | 58 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 59 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 60 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 61 | ((ACCESS) == IWDG_WriteAccess_Disable)) 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup IWDG_prescaler 67 | * @{ 68 | */ 69 | 70 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 71 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 72 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 73 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 74 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 75 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 76 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 77 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 78 | ((PRESCALER) == IWDG_Prescaler_8) || \ 79 | ((PRESCALER) == IWDG_Prescaler_16) || \ 80 | ((PRESCALER) == IWDG_Prescaler_32) || \ 81 | ((PRESCALER) == IWDG_Prescaler_64) || \ 82 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 83 | ((PRESCALER) == IWDG_Prescaler_256)) 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup IWDG_Flag 89 | * @{ 90 | */ 91 | 92 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 93 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 94 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU)) 95 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** @defgroup IWDG_Exported_Macros 105 | * @{ 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** @defgroup IWDG_Exported_Functions 113 | * @{ 114 | */ 115 | 116 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 117 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 118 | void IWDG_SetReload(uint16_t Reload); 119 | void IWDG_ReloadCounter(void); 120 | void IWDG_Enable(void); 121 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 122 | 123 | #ifdef __cplusplus 124 | } 125 | #endif 126 | 127 | #endif /* __STM32F10x_IWDG_H */ 128 | /** 129 | * @} 130 | */ 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 141 | -------------------------------------------------------------------------------- /libraries/CMSIS/CM4/DeviceSupport/ST/stm32f429/startup/TASKING/cstart_thumb2.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ;; NOTE: To allow the use of this file for both ARMv6M and ARMv7M, 4 | ;; we will only use 16-bit Thumb intructions. 5 | 6 | .extern _lc_ub_stack ; usr/sys mode stack pointer 7 | .extern _lc_ue_stack ; symbol required by debugger 8 | .extern _lc_ub_table ; ROM to RAM copy table 9 | .extern main 10 | .extern _Exit 11 | .extern exit 12 | .weak exit 13 | .global __get_argcv 14 | .weak __get_argcv 15 | .extern __argcvbuf 16 | .weak __argcvbuf 17 | ;;.extern __init_hardware 18 | 19 | .extern SystemInit 20 | 21 | .if @defined('__PROF_ENABLE__') 22 | .extern __prof_init 23 | .endif 24 | .if @defined('__POSIX__') 25 | .extern posix_main 26 | .extern _posix_boot_stack_top 27 | .endif 28 | 29 | .global _START 30 | 31 | .section .text.cstart 32 | 33 | .thumb 34 | _START: 35 | ;; anticipate possible ROM/RAM remapping 36 | ;; by loading the 'real' program address 37 | ldr r1,=_Next 38 | bx r1 39 | _Next: 40 | ;; initialize the stack pointer 41 | ldr r1,=_lc_ub_stack ; TODO: make this part of the vector table 42 | mov sp,r1 43 | 44 | ; Call the clock system intitialization function. 45 | bl SystemInit 46 | 47 | ;; copy initialized sections from ROM to RAM 48 | ;; and clear uninitialized data sections in RAM 49 | 50 | ldr r3,=_lc_ub_table 51 | movs r0,#0 52 | cploop: 53 | ldr r4,[r3,#0] ; load type 54 | ldr r5,[r3,#4] ; dst address 55 | ldr r6,[r3,#8] ; src address 56 | ldr r7,[r3,#12] ; size 57 | 58 | cmp r4,#1 59 | beq copy 60 | cmp r4,#2 61 | beq clear 62 | b done 63 | 64 | copy: 65 | subs r7,r7,#1 66 | ldrb r1,[r6,r7] 67 | strb r1,[r5,r7] 68 | bne copy 69 | 70 | adds r3,r3,#16 71 | b cploop 72 | 73 | clear: 74 | subs r7,r7,#1 75 | strb r0,[r5,r7] 76 | bne clear 77 | 78 | adds r3,r3,#16 79 | b cploop 80 | 81 | done: 82 | 83 | 84 | .if @defined('__POSIX__') 85 | 86 | ;; posix stack buffer for system upbringing 87 | ldr r0,=_posix_boot_stack_top 88 | ldr r0, [r0] 89 | mov sp,r0 90 | 91 | .else 92 | 93 | ;; load r10 with end of USR/SYS stack, which is 94 | ;; needed in case stack overflow checking is on 95 | ;; NOTE: use 16-bit instructions only, for ARMv6M 96 | ldr r0,=_lc_ue_stack 97 | mov r10,r0 98 | 99 | .endif 100 | 101 | .if @defined('__PROF_ENABLE__') 102 | bl __prof_init 103 | .endif 104 | 105 | .if @defined('__POSIX__') 106 | ;; call posix_main with no arguments 107 | bl posix_main 108 | .else 109 | ;; retrieve argc and argv (default argv[0]==NULL & argc==0) 110 | bl __get_argcv 111 | ldr r1,=__argcvbuf 112 | ;; call main 113 | bl main 114 | .endif 115 | 116 | ;; call exit using the return value from main() 117 | ;; Note. Calling exit will also run all functions 118 | ;; that were supplied through atexit(). 119 | bl exit 120 | 121 | __get_argcv: ; weak definition 122 | movs r0,#0 123 | bx lr 124 | 125 | .ltorg 126 | .endsec 127 | 128 | .calls '_START', ' ' 129 | .calls '_START','__init_vector_table' 130 | .if @defined('__PROF_ENABLE__') 131 | .calls '_START','__prof_init' 132 | .endif 133 | .if @defined('__POSIX__') 134 | .calls '_START','posix_main' 135 | .else 136 | .calls '_START','__get_argcv' 137 | .calls '_START','main' 138 | .endif 139 | .calls '_START','exit' 140 | .calls '_START','',0 141 | 142 | .end 143 | -------------------------------------------------------------------------------- /libraries/stm32f429_StdPeriph_Driver/Common/lcd_log.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file lcd_log.h 4 | * @author MCD Application Team 5 | * @version V5.0.2 6 | * @date 05-March-2012 7 | * @brief header for the lcd_log.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __LCD_LOG_H__ 30 | #define __LCD_LOG_H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | 34 | #include "lcd_log_conf.h" 35 | 36 | /** @addtogroup Utilities 37 | * @{ 38 | */ 39 | 40 | /** @addtogroup STM32_EVAL 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup Common 45 | * @{ 46 | */ 47 | 48 | /** @addtogroup LCD_LOG 49 | * @{ 50 | */ 51 | 52 | /** @defgroup LCD_LOG 53 | * @brief 54 | * @{ 55 | */ 56 | 57 | 58 | /** @defgroup LCD_LOG_Exported_Defines 59 | * @{ 60 | */ 61 | #ifdef __GNUC__ 62 | /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf 63 | set to 'Yes') calls __io_putchar() */ 64 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 65 | #else 66 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 67 | #endif /* __GNUC__ */ 68 | 69 | /** These value can be changed by user */ 70 | 71 | #ifdef LCD_SCROLL_ENABLED 72 | #define LCD_CACHE_DEPTH (YWINDOW_SIZE + CACHE_SIZE) 73 | #else 74 | #define LCD_CACHE_DEPTH YWINDOW_SIZE 75 | #endif 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup LCD_LOG_Exported_Types 81 | * @{ 82 | */ 83 | typedef struct _LCD_LOG_line 84 | { 85 | uint8_t line[XWINDOW_MAX]; 86 | uint16_t color; 87 | 88 | }LCD_LOG_line; 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup LCD_LOG_Exported_Macros 95 | * @{ 96 | */ 97 | #define LCD_ErrLog(...) LCD_LineColor = Red;\ 98 | printf("ERROR: ") ;\ 99 | printf(__VA_ARGS__);\ 100 | LCD_LineColor = LCD_LOG_DEFAULT_COLOR 101 | 102 | #define LCD_UsrLog(...) LCD_LineColor = LCD_LOG_DEFAULT_COLOR;\ 103 | printf(__VA_ARGS__);\ 104 | 105 | 106 | #define LCD_DbgLog(...) LCD_LineColor = Cyan;\ 107 | printf(__VA_ARGS__);\ 108 | LCD_LineColor = LCD_LOG_DEFAULT_COLOR 109 | /** 110 | * @} 111 | */ 112 | 113 | /** @defgroup LCD_LOG_Exported_Variables 114 | * @{ 115 | */ 116 | extern uint16_t LCD_LineColor; 117 | /** 118 | * @} 119 | */ 120 | 121 | /** @defgroup LCD_LOG_Exported_FunctionsPrototype 122 | * @{ 123 | */ 124 | void LCD_LOG_Init(void); 125 | void LCD_LOG_DeInit(void); 126 | void LCD_LOG_SetHeader(uint8_t *Title); 127 | void LCD_LOG_SetFooter(uint8_t *Status); 128 | void LCD_LOG_ClearTextZone(void); 129 | #ifdef LCD_SCROLL_ENABLED 130 | ErrorStatus LCD_LOG_ScrollBack(void); 131 | ErrorStatus LCD_LOG_ScrollForward(void); 132 | #endif 133 | /** 134 | * @} 135 | */ 136 | 137 | 138 | #endif /* __LCD_LOG_H__ */ 139 | 140 | /** 141 | * @} 142 | */ 143 | 144 | /** 145 | * @} 146 | */ 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 161 | -------------------------------------------------------------------------------- /include/pthreadtypes.h: -------------------------------------------------------------------------------- 1 | #ifndef PTHREADTYPES_H 2 | #define PTHREADTYPES_H 3 | 4 | #include "task.h" 5 | 6 | /* TODO 7 | * Copy from Linux pthread library. 8 | * Should verify whether it's in use or not 9 | */ 10 | #define SIZEOF_PTHREAD_ATTR_T 36 11 | #define SIZEOF_PTHREAD_MUTEX_T 24 12 | #define SIZEOF_PTHREAD_MUTEXATTR_T 4 13 | #define SIZEOF_PTHREAD_COND_T 48 14 | #define SIZEOF_PTHREAD_COND_COMPAT_T 12 15 | #define SIZEOF_PTHREAD_CONDATTR_T 4 16 | #define SIZEOF_PTHREAD_RWLOCK_T 32 17 | #define SIZEOF_PTHREAD_RWLOCKATTR_T 8 18 | #define SIZEOF_PTHREAD_BARRIER_T 20 19 | #define SIZEOF_PTHREAD_BARRIERATTR_T 4 20 | 21 | //typedef unsigned long int pthread_t; 22 | 23 | struct sched_param { 24 | int policy; 25 | int sched_priority; 26 | }; 27 | 28 | typedef struct pthread_attr_struct { 29 | unsigned int stack_size; 30 | int detachstate; 31 | int policy; 32 | struct sched_param sched_param; 33 | } pthread_attr_t; 34 | 35 | 36 | struct pthread_struct { 37 | struct task_control_block* tcb; 38 | pthread_attr_t* attr; 39 | int released; 40 | void** value_ptr; 41 | }; 42 | 43 | typedef struct pthread_struct* pthread_t; 44 | 45 | typedef struct pthread_internal_slist { 46 | struct pthread_internal_slist *next; 47 | } pthread_slist_t; 48 | 49 | 50 | /******* FROM LINUX PTHREAD LIBRARY ********/ 51 | /* Data structures for mutex handling. The structure of the attribute 52 | type is not exposed on purpose. */ 53 | typedef union { 54 | struct pthread_mutex_s { 55 | int lock; 56 | unsigned int count; 57 | int state; 58 | /* KIND must stay at this position in the structure to maintain 59 | binary compatibility. */ 60 | int kind; 61 | unsigned int nusers; 62 | int spins; 63 | } data; 64 | char size[SIZEOF_PTHREAD_MUTEX_T]; 65 | long int align; 66 | } pthread_mutex_t; 67 | 68 | /* Mutex spins initializer used by PTHREAD_MUTEX_INITIALIZER. */ 69 | #define PTHREAD_SPINS 0 70 | 71 | typedef union { 72 | char size[SIZEOF_PTHREAD_MUTEXATTR_T]; 73 | long int align; 74 | } pthread_mutexattr_t; 75 | 76 | //------------------------check to here-------------------- 77 | 78 | /* Data structure for conditional variable handling. The structure of 79 | the attribute type is not exposed on purpose. */ 80 | typedef union { 81 | struct { 82 | int lock; 83 | unsigned int futex; 84 | unsigned long long int total_seq; 85 | unsigned long long int wakeup_seq; 86 | unsigned long long int woken_seq; 87 | void *mutex; 88 | unsigned int nwaiters; 89 | unsigned int broadcast_seq; 90 | } data; 91 | char size[SIZEOF_PTHREAD_COND_T]; 92 | long long int align; 93 | } pthread_cond_t; 94 | 95 | typedef union { 96 | char size[SIZEOF_PTHREAD_CONDATTR_T]; 97 | long int align; 98 | } pthread_condattr_t; 99 | 100 | 101 | /* Keys for thread-specific data */ 102 | typedef unsigned int pthread_key_t; 103 | 104 | 105 | /* Once-only execution */ 106 | typedef int pthread_once_t; 107 | 108 | 109 | #if defined USE_UNIX98 || defined USE_XOPEN2K 110 | /* Data structure for read-write lock variable handling. The 111 | structure of the attribute type is not exposed on purpose. */ 112 | typedef union 113 | { 114 | struct 115 | { 116 | int lock; 117 | unsigned int nr_readers; 118 | unsigned int readers_wakeup; 119 | unsigned int writer_wakeup; 120 | unsigned int nr_readers_queued; 121 | unsigned int nr_writers_queued; 122 | /* FLAGS must stay at this position in the structure to maintain 123 | binary compatibility. */ 124 | unsigned char flags; 125 | unsigned char shared; 126 | unsigned char pad1; 127 | unsigned char pad2; 128 | int writer; 129 | } data; 130 | char size[SIZEOF_PTHREAD_RWLOCK_T]; 131 | long int align; 132 | } pthread_rwlock_t; 133 | 134 | #define PTHREAD_RWLOCK_ELISION_EXTRA 0 135 | 136 | typedef union 137 | { 138 | char size[SIZEOF_PTHREAD_RWLOCKATTR_T]; 139 | long int align; 140 | } pthread_rwlockattr_t; 141 | #endif 142 | 143 | 144 | #ifdef USE_XOPEN2K 145 | /* POSIX spinlock data type. */ 146 | typedef volatile int pthread_spinlock_t; 147 | 148 | 149 | /* POSIX barriers data type. The structure of the type is 150 | deliberately not exposed. */ 151 | typedef union 152 | { 153 | char size[SIZEOF_PTHREAD_BARRIER_T]; 154 | long int align; 155 | } pthread_barrier_t; 156 | 157 | typedef union 158 | { 159 | char size[SIZEOF_PTHREAD_BARRIERATTR_T]; 160 | int align; 161 | } pthread_barrierattr_t; 162 | #endif 163 | 164 | 165 | #endif 166 | 167 | -------------------------------------------------------------------------------- /libraries/stm32f429_StdPeriph_Driver/inc/stm32f4xx_rng.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_rng.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the Random 8 | * Number Generator(RNG) firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_RNG_H 31 | #define __STM32F4xx_RNG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup RNG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup RNG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup RNG_flags_definition 56 | * @{ 57 | */ 58 | #define RNG_FLAG_DRDY ((uint8_t)0x0001) /*!< Data ready */ 59 | #define RNG_FLAG_CECS ((uint8_t)0x0002) /*!< Clock error current status */ 60 | #define RNG_FLAG_SECS ((uint8_t)0x0004) /*!< Seed error current status */ 61 | 62 | #define IS_RNG_GET_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_DRDY) || \ 63 | ((RNG_FLAG) == RNG_FLAG_CECS) || \ 64 | ((RNG_FLAG) == RNG_FLAG_SECS)) 65 | #define IS_RNG_CLEAR_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_CECS) || \ 66 | ((RNG_FLAG) == RNG_FLAG_SECS)) 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup RNG_interrupts_definition 72 | * @{ 73 | */ 74 | #define RNG_IT_CEI ((uint8_t)0x20) /*!< Clock error interrupt */ 75 | #define RNG_IT_SEI ((uint8_t)0x40) /*!< Seed error interrupt */ 76 | 77 | #define IS_RNG_IT(IT) ((((IT) & (uint8_t)0x9F) == 0x00) && ((IT) != 0x00)) 78 | #define IS_RNG_GET_IT(RNG_IT) (((RNG_IT) == RNG_IT_CEI) || ((RNG_IT) == RNG_IT_SEI)) 79 | /** 80 | * @} 81 | */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /* Exported macro ------------------------------------------------------------*/ 88 | /* Exported functions --------------------------------------------------------*/ 89 | 90 | /* Function used to set the RNG configuration to the default reset state *****/ 91 | void RNG_DeInit(void); 92 | 93 | /* Configuration function *****************************************************/ 94 | void RNG_Cmd(FunctionalState NewState); 95 | 96 | /* Get 32 bit Random number function ******************************************/ 97 | uint32_t RNG_GetRandomNumber(void); 98 | 99 | /* Interrupts and flags management functions **********************************/ 100 | void RNG_ITConfig(FunctionalState NewState); 101 | FlagStatus RNG_GetFlagStatus(uint8_t RNG_FLAG); 102 | void RNG_ClearFlag(uint8_t RNG_FLAG); 103 | ITStatus RNG_GetITStatus(uint8_t RNG_IT); 104 | void RNG_ClearITPendingBit(uint8_t RNG_IT); 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | 110 | #endif /*__STM32F4xx_RNG_H */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 121 | -------------------------------------------------------------------------------- /app/lcd_test/main.c: -------------------------------------------------------------------------------- 1 | #include "rtenv.h" 2 | #include "stm32f429i_discovery_lcd.h" 3 | #include "stm32f429i_discovery_ioe.h" 4 | 5 | int main() { 6 | uint16_t linenum = 0; 7 | static TP_STATE *TP_State; 8 | LCD_Init(); 9 | LCD_LayerInit(); 10 | LTDC_Cmd(ENABLE); 11 | LCD_SetLayer(LCD_FOREGROUND_LAYER); 12 | LCD_Clear(LCD_COLOR_WHITE); 13 | // LCD_DrawRect(40,40,40,40); 14 | IOE_Config(); 15 | LCD_SetFont(&Font8x8); 16 | LCD_DisplayStringLine(LINE(32), 17 | (uint8_t *) " Touch Panel Paint "); 18 | LCD_DisplayStringLine(LINE(34), 19 | (uint8_t *) " Example "); 20 | LCD_SetTextColor(LCD_COLOR_BLUE2); 21 | LCD_DrawFullRect(5, 250, 30, 30); 22 | LCD_SetTextColor(LCD_COLOR_CYAN); 23 | LCD_DrawFullRect(40, 250, 30, 30); 24 | LCD_SetTextColor(LCD_COLOR_YELLOW); 25 | LCD_DrawFullRect(75, 250, 30, 30); 26 | LCD_SetTextColor(LCD_COLOR_RED); 27 | LCD_DrawFullRect(5, 288, 30, 30); 28 | LCD_SetTextColor(LCD_COLOR_BLUE); 29 | LCD_DrawFullRect(40, 288, 30, 30); 30 | LCD_SetTextColor(LCD_COLOR_GREEN); 31 | LCD_DrawFullRect(75, 288, 30, 30); 32 | LCD_SetTextColor(LCD_COLOR_MAGENTA); 33 | LCD_DrawFullRect(145, 288, 30, 30); 34 | LCD_SetTextColor(LCD_COLOR_BLACK); 35 | LCD_DrawFullRect(110, 288, 30, 30); 36 | LCD_DrawRect(180, 270, 48, 50); 37 | LCD_SetFont(&Font16x24); 38 | LCD_DisplayChar(LCD_LINE_12, 195, 0x43); 39 | LCD_DrawLine(0, 248, 240, LCD_DIR_HORIZONTAL); 40 | LCD_DrawLine(0, 284, 180, LCD_DIR_HORIZONTAL); 41 | LCD_DrawLine(1, 248, 71, LCD_DIR_VERTICAL); 42 | LCD_DrawLine(37, 248, 71, LCD_DIR_VERTICAL); 43 | LCD_DrawLine(72, 248, 71, LCD_DIR_VERTICAL); 44 | LCD_DrawLine(107, 248, 71, LCD_DIR_VERTICAL); 45 | LCD_DrawLine(142, 284, 36, LCD_DIR_VERTICAL); 46 | LCD_DrawLine(0, 319, 240, LCD_DIR_HORIZONTAL); 47 | while (1) { 48 | TP_State = IOE_TP_GetState(); 49 | 50 | if ((TP_State->TouchDetected) && 51 | ((TP_State->Y < 245) && (TP_State->Y >= 3))) { 52 | if ((TP_State->X >= 237) || (TP_State->X < 3)) { 53 | } 54 | else { 55 | LCD_DrawFullCircle(TP_State->X, TP_State->Y, 3); 56 | } 57 | } 58 | else if ((TP_State->TouchDetected) && (TP_State->Y <= 280) && 59 | (TP_State->Y >= 250) && (TP_State->X >= 5) && 60 | (TP_State->X <= 35)) { 61 | LCD_SetTextColor(LCD_COLOR_BLUE2); 62 | } 63 | else if ((TP_State->TouchDetected) && (TP_State->Y <= 280) && 64 | (TP_State->Y >= 250) && (TP_State->X >= 40) && 65 | (TP_State->X <= 70)) { 66 | LCD_SetTextColor(LCD_COLOR_CYAN); 67 | } 68 | else if ((TP_State->TouchDetected) && (TP_State->Y <= 280) && 69 | (TP_State->Y >= 250) && (TP_State->X >= 75) && 70 | (TP_State->X <= 105)) { 71 | LCD_SetTextColor(LCD_COLOR_YELLOW); 72 | } 73 | else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && 74 | (TP_State->Y >= 288) && (TP_State->X >= 5) && 75 | (TP_State->X <= 35)) { 76 | LCD_SetTextColor(LCD_COLOR_RED); 77 | } 78 | else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && 79 | (TP_State->Y >= 288) && (TP_State->X >= 40) && 80 | (TP_State->X <= 70)) { 81 | LCD_SetTextColor(LCD_COLOR_BLUE); 82 | } 83 | else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && 84 | (TP_State->Y >= 288) && (TP_State->X >= 75) && 85 | (TP_State->X <= 105)) { 86 | LCD_SetTextColor(LCD_COLOR_GREEN); 87 | } 88 | else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && 89 | (TP_State->Y >= 288) && (TP_State->X >= 110) && 90 | (TP_State->X <= 140)) { 91 | LCD_SetTextColor(LCD_COLOR_BLACK); 92 | } 93 | else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && 94 | (TP_State->Y >= 288) && (TP_State->X >= 145) && 95 | (TP_State->X <= 175)) { 96 | LCD_SetTextColor(LCD_COLOR_MAGENTA); 97 | } 98 | else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && 99 | (TP_State->Y >= 270) && (TP_State->X >= 180) && 100 | (TP_State->X <= 230)) { 101 | LCD_SetFont(&Font8x8); 102 | for (linenum = 0; linenum < 31; linenum++) { 103 | LCD_ClearLine(LINE(linenum)); 104 | } 105 | } 106 | else { 107 | } 108 | } 109 | return 0; 110 | } 111 | -------------------------------------------------------------------------------- /libraries/stm32f429_StdPeriph_Driver/inc/stm32f4xx_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the DBGMCU firmware library. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM32F4xx_DBGMCU_H 30 | #define __STM32F4xx_DBGMCU_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "stm32f4xx.h" 38 | 39 | /** @addtogroup STM32F4xx_StdPeriph_Driver 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup DBGMCU 44 | * @{ 45 | */ 46 | 47 | /* Exported types ------------------------------------------------------------*/ 48 | /* Exported constants --------------------------------------------------------*/ 49 | 50 | /** @defgroup DBGMCU_Exported_Constants 51 | * @{ 52 | */ 53 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 54 | #define DBGMCU_STOP ((uint32_t)0x00000002) 55 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 56 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFF8) == 0x00) && ((PERIPH) != 0x00)) 57 | 58 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000001) 59 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00000002) 60 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00000004) 61 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00000008) 62 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00000010) 63 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00000020) 64 | #define DBGMCU_TIM12_STOP ((uint32_t)0x00000040) 65 | #define DBGMCU_TIM13_STOP ((uint32_t)0x00000080) 66 | #define DBGMCU_TIM14_STOP ((uint32_t)0x00000100) 67 | #define DBGMCU_RTC_STOP ((uint32_t)0x00000400) 68 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000800) 69 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00001000) 70 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00200000) 71 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00400000) 72 | #define DBGMCU_I2C3_SMBUS_TIMEOUT ((uint32_t)0x00800000) 73 | #define DBGMCU_CAN1_STOP ((uint32_t)0x02000000) 74 | #define DBGMCU_CAN2_STOP ((uint32_t)0x04000000) 75 | #define IS_DBGMCU_APB1PERIPH(PERIPH) ((((PERIPH) & 0xF91FE200) == 0x00) && ((PERIPH) != 0x00)) 76 | 77 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000001) 78 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00000002) 79 | #define DBGMCU_TIM9_STOP ((uint32_t)0x00010000) 80 | #define DBGMCU_TIM10_STOP ((uint32_t)0x00020000) 81 | #define DBGMCU_TIM11_STOP ((uint32_t)0x00040000) 82 | #define IS_DBGMCU_APB2PERIPH(PERIPH) ((((PERIPH) & 0xFFF8FFFC) == 0x00) && ((PERIPH) != 0x00)) 83 | /** 84 | * @} 85 | */ 86 | 87 | /* Exported macro ------------------------------------------------------------*/ 88 | /* Exported functions --------------------------------------------------------*/ 89 | uint32_t DBGMCU_GetREVID(void); 90 | uint32_t DBGMCU_GetDEVID(void); 91 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 92 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 93 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* __STM32F4xx_DBGMCU_H */ 100 | 101 | /** 102 | * @} 103 | */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 110 | -------------------------------------------------------------------------------- /platform/stm32f10x/stm32_p103.c: -------------------------------------------------------------------------------- 1 | #include "stm32_p103.h" 2 | #include "stm32f10x.h" 3 | #include "stm32f10x_gpio.h" 4 | #include "stm32f10x_rcc.h" 5 | #include "stm32f10x_usart.h" 6 | #include "stm32f10x_exti.h" 7 | #include "misc.h" 8 | 9 | void init_led(void) { 10 | GPIO_InitTypeDef GPIO_InitStructure; 11 | 12 | /* Enable GPIO C clock. */ 13 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); 14 | 15 | /* Set the LED pin state such that the LED is off. The LED is connected 16 | * between power and the microcontroller pin, which makes it turn on when 17 | * the pin is low. 18 | */ 19 | GPIO_WriteBit(GPIOC, GPIO_Pin_12, Bit_SET); 20 | 21 | /* Configure the LED pin as push-pull output. */ 22 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; 23 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 24 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 25 | GPIO_Init(GPIOC, &GPIO_InitStructure); 26 | } 27 | 28 | void init_button(void) { 29 | GPIO_InitTypeDef GPIO_InitStructure; 30 | 31 | /* Enable GPIO A clock */ 32 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 33 | 34 | /* Configure the button pin as a floating input. */ 35 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; 36 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 37 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 38 | GPIO_Init(GPIOC, &GPIO_InitStructure); 39 | } 40 | 41 | void enable_button_interrupts(void) { 42 | EXTI_InitTypeDef EXTI_InitStructure; 43 | NVIC_InitTypeDef NVIC_InitStructure; 44 | 45 | /* Enable the AFIO clock. GPIO_EXTILineConfig sets registers in 46 | * the AFIO. 47 | */ 48 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); 49 | 50 | /* Connect EXTI Line 0 to the button GPIO Pin */ 51 | GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0); 52 | 53 | /* Configure the EXTI line to generate an interrupt when the button is 54 | * pressed. The button pin is high when pressed, so it needs to trigger 55 | * when rising from low to high. */ 56 | EXTI_InitStructure.EXTI_Line = EXTI_Line0; 57 | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; 58 | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; 59 | EXTI_InitStructure.EXTI_LineCmd = ENABLE; 60 | EXTI_Init(&EXTI_InitStructure); 61 | 62 | /* Enable and set Button EXTI Interrupt to the lowest priority */ 63 | NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; 64 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; 65 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; 66 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 67 | NVIC_Init(&NVIC_InitStructure); 68 | } 69 | 70 | void init_rs232(void) { 71 | USART_InitTypeDef USART_InitStructure; 72 | GPIO_InitTypeDef GPIO_InitStructure; 73 | 74 | /* Enable peripheral clocks. */ 75 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE); 76 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); 77 | 78 | /* Configure USART2 Rx pin as floating input. */ 79 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; 80 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 81 | GPIO_Init(GPIOA, &GPIO_InitStructure); 82 | 83 | /* Configure USART2 Tx as alternate function push-pull. */ 84 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; 85 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 86 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 87 | GPIO_Init(GPIOA, &GPIO_InitStructure); 88 | 89 | /* Configure the USART2 */ 90 | USART_InitStructure.USART_BaudRate = 9600; 91 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; 92 | USART_InitStructure.USART_StopBits = USART_StopBits_1; 93 | USART_InitStructure.USART_Parity = USART_Parity_No; 94 | USART_InitStructure.USART_HardwareFlowControl = 95 | USART_HardwareFlowControl_None; 96 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; 97 | USART_Init(USART2, &USART_InitStructure); 98 | USART_Cmd(USART2, ENABLE); 99 | } 100 | 101 | void enable_rs232_interrupts(void) { 102 | NVIC_InitTypeDef NVIC_InitStructure; 103 | 104 | /* Enable transmit and receive interrupts for the USART2. */ 105 | USART_ITConfig(USART2, USART_IT_TXE, DISABLE); 106 | USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); 107 | 108 | /* Enable the USART2 IRQ in the NVIC module (so that the USART2 interrupt 109 | * handler is enabled). */ 110 | NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; 111 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 112 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 113 | NVIC_Init(&NVIC_InitStructure); 114 | } 115 | 116 | void enable_rs232(void) { 117 | /* Enable the RS232 port. */ 118 | USART_Cmd(USART2, ENABLE); 119 | } 120 | -------------------------------------------------------------------------------- /libraries/stm32f429_StdPeriph_Driver/inc/stm32f4xx_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_iwdg.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_IWDG_H 31 | #define __STM32F4xx_IWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup IWDG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup IWDG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup IWDG_WriteAccess 56 | * @{ 57 | */ 58 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 59 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 60 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 61 | ((ACCESS) == IWDG_WriteAccess_Disable)) 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup IWDG_prescaler 67 | * @{ 68 | */ 69 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 70 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 71 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 72 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 73 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 74 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 75 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 76 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 77 | ((PRESCALER) == IWDG_Prescaler_8) || \ 78 | ((PRESCALER) == IWDG_Prescaler_16) || \ 79 | ((PRESCALER) == IWDG_Prescaler_32) || \ 80 | ((PRESCALER) == IWDG_Prescaler_64) || \ 81 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 82 | ((PRESCALER) == IWDG_Prescaler_256)) 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup IWDG_Flag 88 | * @{ 89 | */ 90 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 91 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 92 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU)) 93 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 94 | /** 95 | * @} 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /* Exported macro ------------------------------------------------------------*/ 103 | /* Exported functions --------------------------------------------------------*/ 104 | 105 | /* Prescaler and Counter configuration functions ******************************/ 106 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 107 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 108 | void IWDG_SetReload(uint16_t Reload); 109 | void IWDG_ReloadCounter(void); 110 | 111 | /* IWDG activation function ***************************************************/ 112 | void IWDG_Enable(void); 113 | 114 | /* Flag management function ***************************************************/ 115 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | #endif /* __STM32F4xx_IWDG_H */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 132 | -------------------------------------------------------------------------------- /include/erron.h: -------------------------------------------------------------------------------- 1 | #ifndef ERRON_H 2 | #define ERRON_H 3 | 4 | 5 | #define E2BIG 1 6 | // Argument list too long. 7 | #define EACCES 2 8 | // Permission denied. 9 | #define EADDRINUSE 3 10 | // Address in use. 11 | #define EADDRNOTAVAIL 4 12 | // Address not available. 13 | #define EAFNOSUPPORT 4 14 | // Address family not supported. 15 | #define EAGAIN 6 16 | // Resource unavailable, try again (may be the same value as EWOULDBLOCK). 17 | #define EALREADY 7 18 | // Connection already in progress. 19 | #define EBADF 8 20 | // Bad file descriptor. 21 | #define EBADMSG 9 22 | // Bad message. 23 | #define EBUSY 10 24 | // Device or resource busy. 25 | #define ECANCELED 11 26 | // Operation canceled. 27 | #define ECHILD 12 28 | // No child processes. 29 | #define ECONNABORTED 13 30 | // Connection aborted. 31 | #define ECONNREFUSED 14 32 | // Connection refused. 33 | #define ECONNRESET 15 34 | // Connection reset. 35 | #define EDEADLK 16 36 | // Resource deadlock would occur. 37 | #define EDESTADDRREQ 17 38 | // Destination address required. 39 | #define EDOM 18 40 | // Mathematics argument out of domain of function. 41 | #define EDQUOT 19 42 | // Reserved. 43 | #define EEXIST 20 44 | // File exists. 45 | #define EFAULT 21 46 | // Bad address. 47 | #define EFBIG 22 48 | // File too large. 49 | #define EHOSTUNREACH 23 50 | // Host is unreachable. 51 | #define EIDRM 24 52 | // Identifier removed. 53 | #define EILSEQ 25 54 | // Illegal byte sequence. 55 | #define EINPROGRESS 26 56 | // Operation in progress. 57 | #define EINTR 27 58 | // Interrupted function. 59 | #define EINVAL 28 60 | // Invalid argument. 61 | #define EIO 29 62 | // I/O error. 63 | #define EISCONN 30 64 | // Socket is connected. 65 | #define EISDIR 31 66 | // Is a directory. 67 | #define ELOOP 32 68 | // Too many levels of symbolic links. 69 | #define EMFILE 33 70 | // File descriptor value too large. 71 | #define EMLINK 34 72 | // Too many links. 73 | #define EMSGSIZE 35 74 | // Message too large. 75 | #define EMULTIHOP 36 76 | // Reserved. 77 | #define ENAMETOOLONG 37 78 | // Filename too long. 79 | #define ENETDOWN 38 80 | // Network is down. 81 | #define ENETRESET 39 82 | // Connection aborted by network. 83 | #define ENETUNREACH 40 84 | // Network unreachable. 85 | #define ENFILE 41 86 | // Too many files open in system. 87 | #define ENOBUFS 42 88 | // No buffer space available. 89 | #define ENODATA 43 90 | // OB XSR Option Start No message is available on the STREAM head read queue. Option End 91 | #define ENODEV 44 92 | // No such device. 93 | #define ENOENT 45 94 | // No such file or directory. 95 | #define ENOEXEC 46 96 | // Executable file format error. 97 | #define ENOLCK 47 98 | // No locks available. 99 | #define ENOLINK 48 100 | // Reserved. 101 | #define ENOMEM 49 102 | // Not enough space. 103 | #define ENOMSG 50 104 | // No message of the desired type. 105 | #define ENOPROTOOPT 51 106 | // Protocol not available. 107 | #define ENOSPC 52 108 | // No space left on device. 109 | #define ENOSR 53 110 | // OB XSR Option Start No STREAM resources. Option End 111 | #define ENOSTR 54 112 | // OB XSR Option Start Not a STREAM. Option End 113 | #define ENOSYS 55 114 | // Function not supported. 115 | #define ENOTCONN 56 116 | // The socket is not connected. 117 | #define ENOTDIR 57 118 | // Not a directory or a symbolic link to a directory. 119 | #define ENOTEMPTY 58 120 | // Directory not empty. 121 | #define ENOTRECOVERABLE 59 122 | // State not recoverable. 123 | #define ENOTSOCK 60 124 | // Not a socket. 125 | #define ENOTSUP 61 126 | // Not supported (may be the same value as EOPNOTSUPP). 127 | #define ENOTTY 62 128 | // Inappropriate I/O control operation. 129 | #define ENXIO 63 130 | // No such device or address. 131 | #define EOPNOTSUPP 64 132 | // Operation not supported on socket (may be the same value as ENOTSUP). 133 | #define EOVERFLOW 65 134 | // Value too large to be stored in data type. 135 | #define EOWNERDEAD 66 136 | // Previous owner died. 137 | #define EPERM 67 138 | // Operation not permitted. 139 | #define EPIPE 68 140 | // Broken pipe. 141 | #define EPROTO 69 142 | // Protocol error. 143 | #define EPROTONOSUPPORT 70 144 | // Protocol not supported. 145 | #define EPROTOTYPE 71 146 | // Protocol wrong type for socket. 147 | #define ERANGE 72 148 | // Result too large. 149 | #define EROFS 73 150 | // Read-only file system. 151 | #define ESPIPE 74 152 | // Invalid seek. 153 | #define ESRCH 75 154 | // No such process. 155 | #define ESTALE 76 156 | // Reserved. 157 | #define ETIME 77 158 | // OB XSR Option Start Stream ioctl() timeout. Option End 159 | #define ETIMEDOUT 78 160 | // Connection timed out. 161 | #define ETXTBSY 79 162 | // Text file busy. 163 | #define EWOULDBLOCK 80 164 | // Operation would block (may be the same value as EAGAIN). 165 | #define EXDEV 81 166 | // Cross-device link. 167 | 168 | #endif 169 | 170 | -------------------------------------------------------------------------------- /libraries/CMSIS/CM4/CoreSupport/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2013 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 17. January 2013 5 | * $Revision: V1.4.1 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_common_tables.h 9 | * 10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions 16 | * are met: 17 | * - Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * - Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in 21 | * the documentation and/or other materials provided with the 22 | * distribution. 23 | * - Neither the name of ARM LIMITED nor the names of its contributors 24 | * may be used to endorse or promote products derived from this 25 | * software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * -------------------------------------------------------------------- */ 40 | 41 | #ifndef _ARM_COMMON_TABLES_H 42 | #define _ARM_COMMON_TABLES_H 43 | 44 | #include "arm_math.h" 45 | 46 | extern const uint16_t armBitRevTable[1024]; 47 | extern const q15_t armRecipTableQ15[64]; 48 | extern const q31_t armRecipTableQ31[64]; 49 | extern const q31_t realCoefAQ31[1024]; 50 | extern const q31_t realCoefBQ31[1024]; 51 | extern const float32_t twiddleCoef_16[32]; 52 | extern const float32_t twiddleCoef_32[64]; 53 | extern const float32_t twiddleCoef_64[128]; 54 | extern const float32_t twiddleCoef_128[256]; 55 | extern const float32_t twiddleCoef_256[512]; 56 | extern const float32_t twiddleCoef_512[1024]; 57 | extern const float32_t twiddleCoef_1024[2048]; 58 | extern const float32_t twiddleCoef_2048[4096]; 59 | extern const float32_t twiddleCoef_4096[8192]; 60 | #define twiddleCoef twiddleCoef_4096 61 | extern const q31_t twiddleCoefQ31[6144]; 62 | extern const q15_t twiddleCoefQ15[6144]; 63 | extern const float32_t twiddleCoef_rfft_32[32]; 64 | extern const float32_t twiddleCoef_rfft_64[64]; 65 | extern const float32_t twiddleCoef_rfft_128[128]; 66 | extern const float32_t twiddleCoef_rfft_256[256]; 67 | extern const float32_t twiddleCoef_rfft_512[512]; 68 | extern const float32_t twiddleCoef_rfft_1024[1024]; 69 | extern const float32_t twiddleCoef_rfft_2048[2048]; 70 | extern const float32_t twiddleCoef_rfft_4096[4096]; 71 | 72 | 73 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) 74 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) 75 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) 76 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) 77 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) 78 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) 79 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) 80 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) 81 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) 82 | 83 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH]; 84 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH]; 85 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH]; 86 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; 87 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; 88 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; 89 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH]; 90 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH]; 91 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH]; 92 | 93 | #endif /* ARM_COMMON_TABLES_H */ 94 | -------------------------------------------------------------------------------- /libraries/stm32f10x_StdPeriph_Driver/inc/stm32f10x_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_pwr.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the PWR firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_PWR_H 25 | #define __STM32F10x_PWR_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup PWR 39 | * @{ 40 | */ 41 | 42 | /** @defgroup PWR_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup PWR_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup PVD_detection_level 55 | * @{ 56 | */ 57 | 58 | #define PWR_PVDLevel_2V2 ((uint32_t)0x00000000) 59 | #define PWR_PVDLevel_2V3 ((uint32_t)0x00000020) 60 | #define PWR_PVDLevel_2V4 ((uint32_t)0x00000040) 61 | #define PWR_PVDLevel_2V5 ((uint32_t)0x00000060) 62 | #define PWR_PVDLevel_2V6 ((uint32_t)0x00000080) 63 | #define PWR_PVDLevel_2V7 ((uint32_t)0x000000A0) 64 | #define PWR_PVDLevel_2V8 ((uint32_t)0x000000C0) 65 | #define PWR_PVDLevel_2V9 ((uint32_t)0x000000E0) 66 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_2V2) || ((LEVEL) == PWR_PVDLevel_2V3)|| \ 67 | ((LEVEL) == PWR_PVDLevel_2V4) || ((LEVEL) == PWR_PVDLevel_2V5)|| \ 68 | ((LEVEL) == PWR_PVDLevel_2V6) || ((LEVEL) == PWR_PVDLevel_2V7)|| \ 69 | ((LEVEL) == PWR_PVDLevel_2V8) || ((LEVEL) == PWR_PVDLevel_2V9)) 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup Regulator_state_is_STOP_mode 75 | * @{ 76 | */ 77 | 78 | #define PWR_Regulator_ON ((uint32_t)0x00000000) 79 | #define PWR_Regulator_LowPower ((uint32_t)0x00000001) 80 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \ 81 | ((REGULATOR) == PWR_Regulator_LowPower)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup STOP_mode_entry 87 | * @{ 88 | */ 89 | 90 | #define PWR_STOPEntry_WFI ((uint8_t)0x01) 91 | #define PWR_STOPEntry_WFE ((uint8_t)0x02) 92 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE)) 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** @defgroup PWR_Flag 99 | * @{ 100 | */ 101 | 102 | #define PWR_FLAG_WU ((uint32_t)0x00000001) 103 | #define PWR_FLAG_SB ((uint32_t)0x00000002) 104 | #define PWR_FLAG_PVDO ((uint32_t)0x00000004) 105 | #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 106 | ((FLAG) == PWR_FLAG_PVDO)) 107 | 108 | #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB)) 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @defgroup PWR_Exported_Macros 118 | * @{ 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** @defgroup PWR_Exported_Functions 126 | * @{ 127 | */ 128 | 129 | void PWR_DeInit(void); 130 | void PWR_BackupAccessCmd(FunctionalState NewState); 131 | void PWR_PVDCmd(FunctionalState NewState); 132 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); 133 | void PWR_WakeUpPinCmd(FunctionalState NewState); 134 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 135 | void PWR_EnterSTANDBYMode(void); 136 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); 137 | void PWR_ClearFlag(uint32_t PWR_FLAG); 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* __STM32F10x_PWR_H */ 144 | /** 145 | * @} 146 | */ 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 157 | -------------------------------------------------------------------------------- /platform/stm32f429/stm32f4xx_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ****************************************************************************** 3 | * * @file USART/HyperTerminal_Interrupt/stm32f4xx_conf.h 4 | * * @author MCD Application Team 5 | * * @version V1.0.1 6 | * * @date 13-April-2012 7 | * * @brief Library configuration file. 8 | * ****************************************************************************** 9 | * * @attention 10 | * * 11 | * *

© COPYRIGHT 2012 STMicroelectronics

12 | * * 13 | * * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * * You may not use this file except in compliance with the License. 15 | * * You may obtain a copy of the License at: 16 | * * 17 | * * http://www.st.com/software_license_agreement_liberty_v2 18 | * * 19 | * * Unless required by applicable law or agreed to in writing, software 20 | * * distributed under the License is distributed on an "AS IS" BASIS, 21 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * * See the License for the specific language governing permissions and 23 | * * limitations under the License. 24 | * * 25 | * ****************************************************************************** 26 | * */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM32F4xx_CONF_H 30 | #define __STM32F4xx_CONF_H 31 | 32 | 33 | #if defined (HSE_VALUE) 34 | /* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */ 35 | #undef HSE_VALUE 36 | #define HSE_VALUE ((uint32_t)8000000) 37 | #endif /* HSE_VALUE */ 38 | 39 | /* Includes ------------------------------------------------------------------*/ 40 | /* Uncomment the line below to enable peripheral header file inclusion */ 41 | //#include "stm32f4xx_adc.h" 42 | //#include "stm32f4xx_can.h" 43 | //#include "stm32f4xx_crc.h" 44 | //#include "stm32f4xx_cryp.h" 45 | //#include "stm32f4xx_dac.h" 46 | //#include "stm32f4xx_dbgmcu.h" 47 | //#include "stm32f4xx_dcmi.h" 48 | #include "stm32f4xx_dma.h" 49 | #include "stm32f4xx_exti.h" 50 | //#include "stm32f4xx_flash.h" 51 | //#include "stm32f4xx_fsmc.h" 52 | //#include "stm32f4xx_hash.h" 53 | #include "stm32f4xx_gpio.h" 54 | #include "stm32f4xx_i2c.h" 55 | //#include "stm32f4xx_iwdg.h" 56 | //#include "stm32f4xx_pwr.h" 57 | #include "stm32f4xx_rcc.h" 58 | //#include "stm32f4xx_rng.h" 59 | //#include "stm32f4xx_rtc.h" 60 | //#include "stm32f4xx_sdio.h" 61 | //#include "stm32f429i_discovery_lcd.h" 62 | #include "stm32f4xx_ltdc.h" 63 | #include "stm32f4xx_spi.h" 64 | #include "stm32f4xx_syscfg.h" 65 | //#include "stm32f4xx_tim.h" 66 | #include "stm32f4xx_usart.h" 67 | #include "stm32f4xx_dma2d.h" 68 | //#include "stm32f4xx_wwdg.h" 69 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 70 | 71 | /* Exported types ------------------------------------------------------------*/ 72 | /* Exported constants --------------------------------------------------------*/ 73 | 74 | /* If an external clock source is used, then the value of the following define 75 | * should be set to the value of the external clock source, else, if no external 76 | * clock is used, keep this define commented */ 77 | /*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */ 78 | 79 | 80 | /* Uncomment the line below to expanse the "assert_param" macro in the 81 | * Standard Peripheral Library drivers code */ 82 | /* #define USE_FULL_ASSERT 1 */ 83 | 84 | /* Exported macro ------------------------------------------------------------*/ 85 | #ifdef USE_FULL_ASSERT 86 | 87 | /** 88 | * * @brief The assert_param macro is used for function's parameters check. 89 | * * @param expr: If expr is false, it calls assert_failed function 90 | * * which reports the name of the source file and the source 91 | * * line number of the call that failed. 92 | * * If expr is true, it returns no value. 93 | * * @retval None 94 | * */ 95 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 96 | /* Exported functions ------------------------------------------------------- */ 97 | void assert_failed(uint8_t* file, uint32_t line); 98 | #else 99 | #define assert_param(expr) ((void)0) 100 | #endif /* USE_FULL_ASSERT */ 101 | 102 | #endif /* __STM32F4xx_CONF_H */ 103 | 104 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 105 | 106 | -------------------------------------------------------------------------------- /tool/mkromfs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define ERR_NO_DIR 1 12 | #define ERR_NO_OUT 2 13 | #define ERR_OPEN_OUT 3 14 | #define ERR_OPEN_FILE 4 15 | 16 | #define ERR(err) (ERR_##err) 17 | 18 | #define PATH_LEN 31 19 | #define BUF_SIZE 1024 20 | 21 | struct entry { 22 | uint32_t parent; 23 | uint32_t prev; 24 | uint32_t next; 25 | uint32_t isdir; 26 | uint32_t len; 27 | uint8_t name[PATH_LEN + 1]; 28 | }; 29 | 30 | size_t fwrite_off(const void *ptr, size_t size, size_t nmemb, FILE *stream, 31 | off_t off) { 32 | fseek(stream, off, SEEK_SET); 33 | return fwrite(ptr, size, nmemb, stream); 34 | } 35 | 36 | int procfile(const char *filename, char *fullpath, FILE *outfile) { 37 | FILE *infile; 38 | char buf[BUF_SIZE]; 39 | size_t size; 40 | 41 | infile = fopen(fullpath, "rb"); 42 | if (!infile) { 43 | error(ERR(OPEN_FILE), errno, "Cannot open file '%s'\n", fullpath); 44 | } 45 | 46 | while ((size = fread(buf, 1, BUF_SIZE, infile))) { 47 | fwrite(buf, 1, size, outfile); 48 | } 49 | 50 | fclose(infile); 51 | 52 | return ftell(outfile); 53 | } 54 | 55 | int procdir(const char *dirname, char *fullpath, FILE *outfile) { 56 | DIR *dirfile; 57 | struct dirent *direntry; 58 | 59 | strcat(fullpath, "/"); 60 | size_t fullpath_len = strlen(fullpath); 61 | 62 | dirfile = opendir(fullpath); 63 | if (!dirfile) { 64 | error(ERR(OPEN_OUT), errno, "Cannot open directory '%s'\n", fullpath); 65 | } 66 | 67 | int parent_entry = ftell(outfile) - sizeof(struct entry); 68 | int prev_entry = 0; /* prev = 0 means no prev */ 69 | int next_entry = ftell(outfile); 70 | int this_entry = next_entry; 71 | 72 | struct entry entry; 73 | entry.parent = parent_entry; 74 | entry.prev = 0; 75 | entry.next = 0; 76 | 77 | /* Scan entries */ 78 | while ((direntry = readdir(dirfile))) { 79 | /* Ignore hidden files and itself */ 80 | if (*direntry->d_name == '.') 81 | continue; 82 | 83 | this_entry = next_entry; 84 | 85 | entry.prev = prev_entry; 86 | strncpy((void *) entry.name, direntry->d_name, PATH_LEN); 87 | 88 | strcpy(fullpath + fullpath_len, direntry->d_name); 89 | 90 | /* Reservion for this entry */ 91 | fwrite_off(&entry, sizeof(entry), 1, outfile, this_entry); 92 | 93 | /* Process entry */ 94 | if (direntry->d_type == DT_DIR) { 95 | entry.isdir = 1; 96 | next_entry = procdir(direntry->d_name, fullpath, outfile); 97 | } 98 | else { 99 | entry.isdir = 0; 100 | next_entry = procfile(direntry->d_name, fullpath, outfile); 101 | } 102 | 103 | entry.next = next_entry; 104 | entry.len = next_entry - (this_entry + sizeof(entry)); 105 | 106 | /* Write entry */ 107 | fwrite_off(&entry, sizeof(entry), 1, outfile, this_entry); 108 | 109 | prev_entry = this_entry; 110 | } 111 | 112 | /* Clear next of last entry */ 113 | if (entry.next != 0) { 114 | entry.next = 0; 115 | fwrite_off(&entry, sizeof(entry), 1, outfile, this_entry); 116 | } 117 | 118 | 119 | closedir(dirfile); 120 | 121 | return next_entry; 122 | } 123 | 124 | int main(int argc, char *argv[]) { 125 | int c; 126 | FILE *outfile; 127 | const char *outname = NULL; 128 | const char *dirname = NULL; 129 | char fullpath[PATH_MAX] = {0}; 130 | 131 | while ((c = getopt(argc, argv, "o:d:")) != -1) { 132 | switch (c) { 133 | case 'd': 134 | if (optarg) 135 | dirname = optarg; 136 | else 137 | error(ERR(NO_DIR), EINVAL, 138 | "-d option need a input directory.\n"); 139 | break; 140 | case 'o': 141 | if (optarg) 142 | outname = optarg; 143 | else 144 | error(ERR(NO_OUT), EINVAL, 145 | "-o option need a output file name.\n"); 146 | break; 147 | default:; 148 | } 149 | } 150 | 151 | if (!dirname) { 152 | dirname = "."; 153 | } 154 | 155 | if (outname) 156 | outfile = fopen(outname, "wb"); 157 | else 158 | outfile = stdout; 159 | 160 | if (!outfile) { 161 | error(ERR(OPEN_OUT), errno, "Cannot open output file '%s'\n", outname); 162 | } 163 | 164 | strcpy(fullpath, dirname); 165 | 166 | /* Reservion for root entry */ 167 | struct entry entry; 168 | fwrite_off(&entry, sizeof(entry), 1, outfile, 0); 169 | size_t end = procdir(dirname, fullpath, outfile); 170 | 171 | entry.parent = 0; 172 | entry.prev = 0; 173 | entry.next = 0; 174 | entry.isdir = 1; 175 | entry.len = end - sizeof(entry); 176 | fwrite_off(&entry, sizeof(entry), 1, outfile, 0); 177 | 178 | /* Clean up*/ 179 | fclose(outfile); 180 | 181 | return 0; 182 | } 183 | -------------------------------------------------------------------------------- /src/trace.c: -------------------------------------------------------------------------------- 1 | #include "string.h" 2 | #include "host.h" 3 | #include "trace.h" 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | #define NVIC_INTERRUPTx_PRIORITY ((volatile unsigned char *) 0xE000E400) 10 | int logfile = 0; 11 | extern int tick_count; 12 | int prev_t = 0; 13 | 14 | int get_interrupt_priority(int interrupt) { 15 | if (interrupt < 240) 16 | return NVIC_INTERRUPTx_PRIORITY[interrupt]; 17 | return -1; 18 | } 19 | 20 | unsigned int get_reload() { return *(unsigned int *) 0xE000E014; } 21 | 22 | unsigned int get_current() { return *(unsigned int *) 0xE000E018; } 23 | 24 | int __attribute__((naked)) get_current_interrupt_number() { 25 | __asm volatile( 26 | "mrs r0, ipsr\n" 27 | "bx lr \n"); 28 | } 29 | 30 | int _snprintf_int(int num, char *buf, int buf_size) { 31 | int len = 1; 32 | char *p; 33 | int i = num < 0 ? -num : num; 34 | 35 | for (; i >= 10; i /= 10, len++) 36 | ; 37 | 38 | if (num < 0) 39 | len++; 40 | 41 | i = num; 42 | p = buf + len - 1; 43 | do { 44 | if (p < buf + buf_size) 45 | *p-- = '0' + i % 10; 46 | i /= 10; 47 | } while (i != 0); 48 | 49 | if (num < 0) 50 | *p = '-'; 51 | 52 | return len < buf_size ? len : buf_size; 53 | } 54 | 55 | 56 | int snprintf(char *buf, size_t size, const char *format, ...) { 57 | va_list ap; 58 | char *dest = buf; 59 | char *last = buf + size; 60 | char ch; 61 | 62 | va_start(ap, format); 63 | for (ch = *format++; dest < last && ch; ch = *format++) { 64 | if (ch == '%') { 65 | ch = *format++; 66 | switch (ch) { 67 | case 's': { 68 | char *str = va_arg(ap, char *); 69 | /* strncpy */ 70 | while (dest < last) { 71 | if ((*dest = *str++)) 72 | dest++; 73 | else 74 | break; 75 | } 76 | } break; 77 | case 'd': { 78 | int num = va_arg(ap, int); 79 | dest += _snprintf_int(num, dest, last - dest); 80 | } break; 81 | case '%': 82 | *dest++ = ch; 83 | break; 84 | default: 85 | return -1; 86 | } 87 | } 88 | else { 89 | *dest++ = ch; 90 | } 91 | } 92 | va_end(ap); 93 | 94 | if (dest < last) 95 | *dest = 0; 96 | else 97 | *--dest = 0; 98 | 99 | return dest - buf; 100 | } 101 | 102 | float get_time() { 103 | unsigned int const *reload = (void *) 0xE000E014; 104 | unsigned int const *current = (void *) 0xE000E018; 105 | 106 | return (tick_count) + ((*reload - *current) / (*reload)); 107 | } 108 | 109 | 110 | void trace_task_create(void *task, const char *task_name, 111 | unsigned int priority) { 112 | char buf[128]; 113 | int len = snprintf(buf, 128, "task %d %d %s\n", task, priority, task_name); 114 | host_action(SYS_WRITE, logfile, buf, len); 115 | } 116 | 117 | void trace_task_switch(void *prev_task, unsigned int prev_tick, 118 | void *curr_task) { 119 | int sub = prev_tick - get_current(); 120 | char buf[128]; 121 | int len = snprintf(buf, 128, "switch %d %d %d %d %d %d %d\n", prev_task, 122 | curr_task, tick_count, get_reload(), prev_tick, 123 | get_current(), sub); 124 | host_action(SYS_WRITE, logfile, buf, len); 125 | } 126 | 127 | void trace_create_mutex(void *mutex) { 128 | char buf[128]; 129 | int len = snprintf(buf, 128, "mutex %d %d\n", get_time(), mutex); 130 | host_action(SYS_WRITE, logfile, buf, len); 131 | } 132 | 133 | void trace_queue_create(void *queue, int queue_type, unsigned int queue_size) { 134 | char buf[128]; 135 | int len = snprintf(buf, 128, "queue create %d %d %d %d\n", get_time(), 136 | queue, queue_type, queue_size); 137 | host_action(SYS_WRITE, logfile, buf, len); 138 | } 139 | 140 | void trace_queue_send(void *task, void *queue) { 141 | char buf[128]; 142 | int len = 143 | snprintf(buf, 128, "queue send %d %d %d\n", get_time(), task, queue); 144 | host_action(SYS_WRITE, logfile, buf, len); 145 | } 146 | 147 | void trace_queue_recv(void *task, void *queue) { 148 | char buf[128]; 149 | int len = 150 | snprintf(buf, 128, "queue recv %d %d %d\n", get_time(), task, queue); 151 | host_action(SYS_WRITE, logfile, buf, len); 152 | } 153 | 154 | void trace_queue_block(void *task, void *queue) { 155 | char buf[128]; 156 | int len = 157 | snprintf(buf, 128, "queue block %d %d %d\n", get_time(), task, queue); 158 | host_action(SYS_WRITE, logfile, buf, len); 159 | } 160 | 161 | void trace_interrupt_in() { 162 | prev_t = get_current(); 163 | char buf[128]; 164 | int number = get_current_interrupt_number(); 165 | int len = snprintf(buf, 128, "interrupt in %d %d %d\n", prev_t, number, 166 | get_interrupt_priority(number)); 167 | host_action(SYS_WRITE, logfile, buf, len); 168 | } 169 | 170 | void trace_interrupt_out() { 171 | int t = get_current(); 172 | char buf[128]; 173 | int number = get_current_interrupt_number(); 174 | int len = snprintf(buf, 128, "interrupt out %d %d\n", prev_t - t, number); 175 | host_action(SYS_WRITE, logfile, buf, len); 176 | } 177 | -------------------------------------------------------------------------------- /libraries/stm32f429_StdPeriph_Driver/inc/stm32f429i_discovery_sdram.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f429i_discovery_sdram.h 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 28-October-2013 7 | * @brief This file contains all the functions prototypes for the 8 | * stm324x9i_disco_sdram.c driver. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32429I_DISCO_SDRAM_H 31 | #define __STM32429I_DISCO_SDRAM_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup Utilities 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup STM32F4_EVAL 45 | * @{ 46 | */ 47 | 48 | /** @addtogroup STM32F429I_DISCOVERY 49 | * @{ 50 | */ 51 | 52 | /** @addtogroup STM32F429I_DISCOVERY_SDRAM 53 | * @{ 54 | */ 55 | 56 | /** @defgroup STM32429I_DISCO_SDRAM_Private_Defines 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @brief FMC SDRAM Bank address 62 | */ 63 | #define SDRAM_BANK_ADDR ((uint32_t)0xD0000000) 64 | 65 | /** 66 | * @brief FMC SDRAM Memory Width 67 | */ 68 | /* #define SDRAM_MEMORY_WIDTH FMC_SDMemory_Width_8b */ 69 | #define SDRAM_MEMORY_WIDTH FMC_SDMemory_Width_16b 70 | 71 | /** 72 | * @brief FMC SDRAM CAS Latency 73 | */ 74 | /* #define SDRAM_CAS_LATENCY FMC_CAS_Latency_2 */ 75 | #define SDRAM_CAS_LATENCY FMC_CAS_Latency_3 76 | 77 | /** 78 | * @brief FMC SDRAM Memory clock period 79 | */ 80 | #define SDCLOCK_PERIOD FMC_SDClock_Period_2 /* Default configuration used with LCD */ 81 | /* #define SDCLOCK_PERIOD FMC_SDClock_Period_3 */ 82 | 83 | /** 84 | * @brief FMC SDRAM Memory Read Burst feature 85 | */ 86 | #define SDRAM_READBURST FMC_Read_Burst_Disable /* Default configuration used with LCD */ 87 | /* #define SDRAM_READBURST FMC_Read_Burst_Enable */ 88 | 89 | /** 90 | * @brief FMC SDRAM Bank Remap 91 | */ 92 | /* #define SDRAM_BANK_REMAP */ 93 | 94 | 95 | 96 | /** 97 | * @brief Uncomment the line below if you want to use user defined Delay function 98 | * (for precise timing), otherwise default _delay_ function defined within 99 | * this driver is used (less precise timing). 100 | */ 101 | 102 | /* #define USE_Delay */ 103 | 104 | #ifdef USE_Delay 105 | #define __Delay Delay /* User can provide more timing precise __Delay function 106 | (with 10ms time base), using SysTick for example */ 107 | #else 108 | #define __Delay delay /* Default __Delay function with less precise timing */ 109 | #endif 110 | 111 | /** 112 | * @brief FMC SDRAM Mode definition register defines 113 | */ 114 | #define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000) 115 | #define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001) 116 | #define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002) 117 | #define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004) 118 | #define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000) 119 | #define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008) 120 | #define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020) 121 | #define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030) 122 | #define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000) 123 | #define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) 124 | #define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) 125 | 126 | /** 127 | * @} 128 | */ 129 | 130 | /** @defgroup STM32429I_DISCO_SDRAM_Exported_Functions 131 | * @{ 132 | */ 133 | void SDRAM_Init(void); 134 | void SDRAM_GPIOConfig(void); 135 | void SDRAM_InitSequence(void); 136 | void SDRAM_WriteBuffer(uint32_t* pBuffer, uint32_t uwWriteAddress, uint32_t uwBufferSize); 137 | void SDRAM_ReadBuffer(uint32_t* pBuffer, uint32_t uwReadAddress, uint32_t uwBufferSize); 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* __STM32429I_DISCO_SDRAM_H */ 144 | 145 | /** 146 | * @} 147 | */ 148 | 149 | /** 150 | * @} 151 | */ 152 | 153 | /** 154 | * @} 155 | */ 156 | 157 | /** 158 | * @} 159 | */ 160 | 161 | /** 162 | * @} 163 | */ 164 | 165 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 166 | -------------------------------------------------------------------------------- /libraries/stm32f10x_StdPeriph_Driver/src/stm32f10x_dbgmcu.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_dbgmcu.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the DBGMCU firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_dbgmcu.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup DBGMCU 30 | * @brief DBGMCU driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup DBGMCU_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup DBGMCU_Private_Defines 43 | * @{ 44 | */ 45 | 46 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) 47 | /** 48 | * @} 49 | */ 50 | 51 | /** @defgroup DBGMCU_Private_Macros 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup DBGMCU_Private_Variables 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup DBGMCU_Private_FunctionPrototypes 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup DBGMCU_Private_Functions 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @brief Returns the device revision identifier. 81 | * @param None 82 | * @retval Device revision identifier 83 | */ 84 | uint32_t DBGMCU_GetREVID(void) 85 | { 86 | return(DBGMCU->IDCODE >> 16); 87 | } 88 | 89 | /** 90 | * @brief Returns the device identifier. 91 | * @param None 92 | * @retval Device identifier 93 | */ 94 | uint32_t DBGMCU_GetDEVID(void) 95 | { 96 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK); 97 | } 98 | 99 | /** 100 | * @brief Configures the specified peripheral and low power mode behavior 101 | * when the MCU under Debug mode. 102 | * @param DBGMCU_Periph: specifies the peripheral and low power mode. 103 | * This parameter can be any combination of the following values: 104 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode 105 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode 106 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode 107 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted 108 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted 109 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted 110 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted 111 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted 112 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted 113 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted 114 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted 115 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted 116 | * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted 117 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted 118 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted 119 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted 120 | * @arg DBGMCU_CAN2_STOP: Debug CAN2 stopped when Core is halted 121 | * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted 122 | * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted 123 | * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted 124 | * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted 125 | * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted 126 | * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted 127 | * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted 128 | * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted 129 | * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted 130 | * @param NewState: new state of the specified peripheral in Debug mode. 131 | * This parameter can be: ENABLE or DISABLE. 132 | * @retval None 133 | */ 134 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState) 135 | { 136 | /* Check the parameters */ 137 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph)); 138 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 139 | 140 | if (NewState != DISABLE) 141 | { 142 | DBGMCU->CR |= DBGMCU_Periph; 143 | } 144 | else 145 | { 146 | DBGMCU->CR &= ~DBGMCU_Periph; 147 | } 148 | } 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 163 | --------------------------------------------------------------------------------