移植到stm32f1,实现手动线赋码控制器功能

This commit is contained in:
ranchuan
2023-09-09 17:27:06 +08:00
parent 8d779a68f3
commit 7baa63de05
382 changed files with 36618 additions and 148064 deletions

View File

@@ -1,5 +1,5 @@
#include "stm32f4xx.h"
#include "stm32f10x.h"
#include <rthw.h>
#include <rtthread.h>
#include "board.h"
@@ -36,14 +36,15 @@ static uint32_t _SysTick_Config(rt_uint32_t ticks)
}
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
static uint32_t g_heap[20*1024/4];
RT_WEAK void *rt_heap_begin_get(void)
{
return (void *)0x10000000;
return (void *)g_heap;
}
RT_WEAK void *rt_heap_end_get(void)
{
return (void *)(0x10000000+0x10000);
return (void *)((int)g_heap+sizeof(g_heap));
}
#endif
@@ -54,9 +55,9 @@ RT_WEAK void *rt_heap_end_get(void)
void rt_hw_board_init()
{
NVIC_SetVectorTable(NVIC_VectTab_FLASH,0x20000);
NVIC_SetVectorTable(NVIC_VectTab_FLASH,0x4000);
// 1ms一个tick
_SysTick_Config (168000000/1000);
_SysTick_Config (72000000/1000);
rt_system_heap_init(rt_heap_begin_get(),rt_heap_end_get());
mem_init();
tempptr_init();

View File

@@ -48,6 +48,13 @@ typedef struct __gpioin_def{
void *private_data;
}gpioin_def;
typedef struct __gpioout_def{
const char *name;
int (*init)(struct __gpioout_def *u);
int (*deinit)(struct __gpioout_def *u);
int (*set)(struct __gpioout_def *u,int state);
void *private_data;
}gpioout_def;
@@ -112,6 +119,22 @@ typedef struct __gpioin_def{
&_gpioin_##name_,\
};
#define gpioout_init_export(name_,init_,deinit_,set_,priv_) \
const static char __dev_##name_##_name[] SECTION(".rodata.devstr") = #name_; \
RT_USED static gpioout_def _gpioout_##name_={\
.name=__dev_##name_##_name,\
.init=init_,\
.deinit=deinit_,\
.set=set_,\
.private_data=priv_,\
};\
RT_USED static const struct dev_struct __dev_##name_ SECTION("devstruct")= \
{ \
__dev_##name_##_name, \
&_gpioout_##name_,\
};
@@ -198,9 +221,9 @@ void __interrupt_enable(uint32_t level);
#define BIT_ADDR(addr, bitnum) (MEM_ADDR(BITBAND(addr, bitnum)))
// 获取输出寄存器地址s=A~I
#define GPIOx_ODR_ADDR(s) (GPIO##s##_BASE+20)
#define GPIOx_ODR_ADDR(s) (GPIO##s##_BASE+12)
// 获取输入寄存器地址s=A~I
#define GPIOx_IDR_ADDR(s) (GPIO##s##_BASE+16)
#define GPIOx_IDR_ADDR(s) (GPIO##s##_BASE+8)
// gpio输出s=A~I,n=0~15
#define PINOUT(s,n) BIT_ADDR(GPIOx_ODR_ADDR(s),n)

View File

@@ -1,4 +1,4 @@
#include "stm32f4xx.h"
#include "stm32f10x.h"
#include "core_delay.h"
#include "rtthread.h"
#include <rthw.h>

View File

@@ -181,6 +181,7 @@ rt_hw_interrupt_thread_switch PROC
HardFault_Handler PROC
; get current context
B .
TST lr, #0x04 ; if(!EXC_RETURN[2])
ITE EQ
MRSEQ r0, msp ; [2]=0 ==> Z=1, get fault context from handler.

View File

@@ -13,7 +13,7 @@
#include <rtdef.h>
#include <board.h>
/* The L1-caches on all Cortex®-M7s are divided into lines of 32 bytes. */
/* The L1-caches on all Cortex-M7s are divided into lines of 32 bytes. */
#define L1CACHE_LINESIZE_BYTE (32)
void rt_hw_cpu_icache_enable(void)

View File

@@ -36,7 +36,7 @@
// <o>the size of main thread<1-4086>
// <i>Default: 512
#define RT_MAIN_THREAD_STACK_SIZE 1024
#define RT_MAIN_THREAD_STACK_SIZE 512
// <c1>using tiny size of memory
// <i>using tiny size of memory
@@ -82,7 +82,7 @@
// <o>The stack size of timer thread <0-8192>
// <i>Default: 512
#define RT_TIMER_THREAD_STACK_SIZE 2048
#define RT_TIMER_THREAD_STACK_SIZE 1024
// <o>The soft-timer tick per second <0-1000>
// <i>Default: 100
@@ -199,7 +199,7 @@
// <<< end of configuration section >>>
#define IDLE_THREAD_STACK_SIZE 2048
#define IDLE_THREAD_STACK_SIZE 1024
#endif