fix port_systick_config bug

This commit is contained in:
acezhao
2019-09-13 22:22:49 +08:00
parent af245f2e5b
commit ad72fb73d2
11 changed files with 83 additions and 1594 deletions

View File

@@ -134,8 +134,6 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/hello_world/TencentOS_tiny/kernel/pm/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/hello_world/Inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/hello_world/TencentOS_tiny/osal/cmsis_os}&quot;"/>
</option>

View File

@@ -39,11 +39,6 @@
<type>2</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/kernel</locationURI>
</link>
<link>
<name>TencentOS_tiny/osal</name>
<type>2</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/osal</locationURI>
</link>
<link>
<name>TencentOS_tiny/arch/risc-v</name>
<type>2</type>

View File

@@ -11,7 +11,7 @@
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1353384052355236260" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1380923165007189689" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>

View File

@@ -42,8 +42,7 @@
#define TOS_CFG_CPU_TICK_PER_SECOND 1000u // 配置TencentOS tiny的tick频率
extern uint32_t SystemCoreClock;
#define TOS_CFG_CPU_CLOCK (SystemCoreClock) // 配置TencentOS tiny CPU频率
#define TOS_CFG_CPU_CLOCK 108000000 // 配置TencentOS tiny CPU频率
#define TOS_CFG_TIMER_AS_PROC 1u // 配置是否将TIMER配置成函数模式

View File

@@ -6,40 +6,21 @@
*/
#include "tos.h"
#include "riscv_encoding.h"
#define RISCV_MSTATUS_MIE (1<<3) /*machine-level interrupt bit*/
#define RISCV_MSTATUS_MPIE (1<<7) /*machine-level pre interrupt bit*/
#define RISCV_MSTATUS_MPP (0x3<<10) /*machine-level MPP bit*/
#define RISCV_MSTATUS_MPP_MPIE (RISCV_MSTATUS_MPIE | RISCV_MSTATUS_MPP)
void port_sched_start();
#define STACK_SIZE 512
char stack[STACK_SIZE];
void debug_task() {
int idle = 0;
int cnt = 0;
while(1) {
idle++;
cnt++;
}
}
#include "cmsis_os.h"
//task1
#define TASK1_STK_SIZE 512
void task1(void *pdata);
#define TASK_SIZE 512
k_task_t k_task_task1;
uint8_t k_task1_stk[TASK1_STK_SIZE];
int shit = 123;
k_task_t k_task_task2;
uint8_t k_task1_stk[TASK_SIZE];
uint8_t k_task2_stk[TASK_SIZE];
int share = 123;
void task1(void *pdata)
{
int c = 0;
int t1 = 0;
while(1)
{
c++;
shit++;
t1++;
share++;
//k_tick_t delay = tos_millisec2tick(10);
//tos_task_delay(delay);
tos_task_yield();
@@ -48,50 +29,34 @@ void task1(void *pdata)
}
}
void task2(void *pdata);
k_task_t k_task_task2;
uint8_t k_task2_stk[TASK1_STK_SIZE];
void task2(void *pdata)
{
int c = 0;
int t2 = 0;
while(1)
{
c--;
shit--;
//osDelay(10);
t2--;
share--;
//tos_task_delay(10);
tos_task_yield();
asm("wfi;");
}
}
uint32_t *stack_sp;
int main(void)
{
osKernelInitialize();
#if 0
while(1) {
asm("csrs mie, %0"::"r"(MIE_MTIE));
asm("csrs mstatus, %0"::"r"(MSTATUS_MIE));
asm("wfi;");
}
#endif
tos_task_create(&k_task_task1, "task1", task1, NULL, 3, k_task1_stk, TASK1_STK_SIZE, 0);
tos_task_create(&k_task_task2, "task2", task2, NULL, 3, k_task2_stk, TASK1_STK_SIZE, 0);
osKernelStart();
uint32_t *sp = stack+STACK_SIZE - 4;
sp = (uint32_t*)(((uint32_t)sp) & 0xFFFFFFF0);
tos_knl_init();
tos_task_create(&k_task_task1, "task1", task1, NULL, 3, k_task1_stk, TASK_SIZE, 0);
tos_task_create(&k_task_task2, "task2", task2, NULL, 3, k_task2_stk, TASK_SIZE, 0);
tos_knl_start();
*(sp - 22) = 0x0ACE0ACE; // Reg R0: argument
*(sp - 30) = 0x1234ABCD; // ra
*(sp - 31) = debug_task;
*(sp - 32) = RISCV_MSTATUS_MPIE | RISCV_MSTATUS_MPP;
sp -= 32;
stack_sp = sp;
port_sched_start();
int c = 0;
while(1) {
while(1)
{
c++;
asm("wfi;");
}
}

View File

@@ -41,12 +41,10 @@ SECTIONS
. = ALIGN(8);
PROVIDE( end = . );
/*
_stack_size = 256;
_stack_size = 128;
.stack ORIGIN(RAM) + LENGTH(RAM) - _stack_size :
{
. = _stack_size;
PROVIDE( _stack_top = . );
} >RAM AT>RAM
*/
}