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

@@ -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;");
}
}