TencentOS tiny port to MSP430FR6972

This commit is contained in:
bourne-h
2019-11-18 19:43:41 +08:00
parent c4d928a42b
commit c985305927
91 changed files with 34319 additions and 2 deletions

View File

@@ -0,0 +1,37 @@
#ifndef DATA_MODEL_H
#define DATA_MODEL_H
#if __DATA_MODEL__ == __DATA_MODEL_SMALL__
#define pushm_x pushm.w
#define popm_x popm.w
#define push_x push.w
#define pop_x pop.w
#define mov_x mov.w
#define cmp_x cmp.w
#endif
#if __DATA_MODEL__ == __DATA_MODEL_MEDIUM__
#define pushm_x pushm.a
#define popm_x popm.a
#define push_x pushx.a
#define pop_x popx.a
#define mov_x mov.w
#define cmp_x cmp.w
#endif
#if __DATA_MODEL__ == __DATA_MODEL_LARGE__
#define pushm_x pushm.a
#define popm_x popm.a
#define push_x pushx.a
#define pop_x popx.a
#define mov_x movx.a
#define cmp_x cmpx.a
#endif
#ifndef pushm_x
#error The assembler options must define one of the following symbols: __DATA_MODEL_SMALL__, __DATA_MODEL_MEDIUM__, or __DATA_MODEL_LARGE__
#endif
#endif /* DATA_MODEL_H */

View File

@@ -0,0 +1,73 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _PORT_H_
#define _PORT_H_
__PORT__ void port_int_disable(void);
__PORT__ void port_int_enable(void);
__PORT__ cpu_cpsr_t port_cpsr_save(void);
__PORT__ void port_cpsr_restore(cpu_cpsr_t cpsr);
__PORT__ void port_cpu_reset(void);
__PORT__ void port_sched_start(void) __NO_RETURN__;
__PORT__ void port_context_switch(void);
__PORT__ void port_irq_context_switch(void);
__PORT__ void port_systick_config(uint32_t cycle_per_tick);
__PORT__ void port_systick_priority_set(uint32_t prio);
#if TOS_CFG_TICKLESS_EN > 0u
__PORT__ void port_systick_resume(void);
__PORT__ void port_systick_suspend(void);
__PORT__ void port_systick_reload(uint32_t cycle_per_tick);
__PORT__ void port_systick_pending_reset(void);
__PORT__ k_time_t port_systick_max_delay_millisecond(void);
#endif
#if TOS_CFG_PWR_MGR_EN > 0u
__PORT__ void port_sleep_mode_enter(void);
__PORT__ void port_stop_mode_enter(void);
__PORT__ void port_standby_mode_enter(void);
#endif
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void HardFault_Handler(void);
__PORT__ void port_fault_diagnosis(void);
#endif
#endif /* _PORT_H_ */

View File

@@ -0,0 +1,116 @@
#include "tos.h"
__PORT__ void port_cpu_reset(void)
{
WDTCTL = WDTPW | 0xff00; // write a wrong Watchdog timer password will cause a PUC(reset)
}
__PORT__ void port_systick_config(uint32_t cycle_per_tick)
{
}
__PORT__ void port_systick_priority_set(uint32_t prio)
{
}
/* MSP430 */
__PORT__ void port_setup_systick(void)
{
const unsigned short aclk_frequency_hz = 32768;
/* Ensure the timer is stopped. */
TA0CTL = 0;
/* Run the timer from the ACLK. */
TA0CTL = TASSEL_1;
/* Clear everything to start with. */
TA0CTL |= TACLR;
/* Set the compare match value according to the tick rate we want. */
TA0CCR0 = aclk_frequency_hz / TOS_CFG_CPU_TICK_PER_SECOND;
/* Enable the interrupts. */
TA0CCTL0 = CCIE;
/* Start up clean. */
TA0CTL |= TACLR;
/* Up mode. */
TA0CTL |= MC_1;
}
/* The MSP430X port uses a callback function to configure its tick interrupt.
*/
#pragma vector=TIMER0_A0_VECTOR
__PORT__ __interrupt __raw void timer0_isr( void )
{
extern void port_systick_isr( void );
__bic_SR_register_on_exit( SCG1 + SCG0 + OSCOFF + CPUOFF );
port_systick_isr();
}
#if TOS_CFG_TICKLESS_EN > 0u
__PORT__ k_time_t port_systick_max_delay_millisecond(void)
{
}
__PORT__ void port_systick_resume(void)
{
}
__PORT__ void port_systick_suspend(void)
{
}
__PORT__ void port_systick_reload(uint32_t cycle_per_tick)
{
}
__PORT__ void port_systick_pending_reset(void)
{
}
#endif
#if TOS_CFG_PWR_MGR_EN > 0u
__PORT__ void port_sleep_mode_enter(void)
{
}
__PORT__ void port_stop_mode_enter(void)
{
}
__PORT__ void port_standby_mode_enter(void)
{
}
#endif
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
k_fault_log_writer("fault diagnosis does not supported in MSP430\n");
}
/*------------------ 430 IAR Compiler-------------------*/
#if defined (__ICC430__) // __IAR_SYSTEMS_ICC__
#endif
#endif /* TOS_CFG_FAULT_BACKTRACE_EN */

View File

@@ -0,0 +1,37 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _PORT_CONFIG_H_
#define _PORT_CONFIG_H_
/* The stack type changes depending on the data model. */
#if( __DATA_MODEL__ == __DATA_MODEL_SMALL__ )
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_16
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_16
#else
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
#endif
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
#define TOS_CFG_CPU_HRTIMER_EN 0u
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
#endif /* _PORT_CONFIG_H_ */

View File

@@ -0,0 +1,148 @@
#include "data_model.h"
;EXPORT
PUBLIC port_int_disable
PUBLIC port_int_enable
PUBLIC port_cpsr_save
PUBLIC port_cpsr_restore
PUBLIC port_sched_start
PUBLIC port_context_switch
PUBLIC port_irq_context_switch
PUBLIC port_systick_isr
;IMPORT
EXTERN k_curr_task
EXTERN k_next_task
EXTERN port_setup_systick
EXTERN systick_handler
EXTERN irq_context_switch_flag
/*-----------------------------------------------------------*/
PORT_SAVE_CONTEXT macro
; Save the remaining registers.
pushm_x #12, r15
mov_x &k_curr_task, r12
mov_x sp, 0( r12 )
endm
PORT_RESTORE_CONTEXT macro
mov_x &k_curr_task, r12
mov_x @r12, sp
popm_x #12, r15
nop
pop.w sr
nop
reta
endm
/*-----------------------------------------------------------*/
;The RTOS systick ISR.
RSEG CODE
EVEN
port_systick_isr:
; /* The sr is not saved in PORT_SAVE_CONTEXT() because port_context_switch() needs
; to save it manually before it gets modified (interrupts get disabled).
; Entering through this interrupt means the SR is already on the stack, but
; this keeps the stack frames identical. */
push.w sr
PORT_SAVE_CONTEXT
calla #systick_handler
cmp.w #0x0,irq_context_switch_flag
mov.w #0x0, &irq_context_switch_flag
jeq skip_context_switch
;k_next_task -> k_curr_task
mov_x &k_next_task,&k_curr_task
skip_context_switch:
PORT_RESTORE_CONTEXT
reti
/*-----------------------------------------------------------*/
port_int_disable:
dint
nop
reta
port_int_enable:
nop
eint
reta
port_cpsr_save:
mov.w SR,R12
dint
nop
reta
port_cpsr_restore:
nop
mov.w R12,SR
nop
reta
port_context_switch:
;/* The sr needs saving before it is modified. */
push.w sr
;/* Now the SR is stacked interrupts can be disabled. */
dint
nop
PORT_SAVE_CONTEXT
;k_next_task -> k_curr_task
mov_x &k_next_task,&k_curr_task
PORT_RESTORE_CONTEXT
reti
port_irq_context_switch:
reti
/*-----------------------------------------------------------*/
;/*
;* Start off the scheduler by initialising the RTOS tick timer, then restoring
;* the context of the first task.
;*/
port_sched_start:
/* Interrupts are turned off here, to ensure a tick does not occur
before or during the call to port_sched_start(). The stacks of
the created tasks contain a status word with interrupts switched on
so interrupts will automatically get re-enabled when the first task
starts to run. */
dint
nop
;/* Setup the hardware to generate the tick. Interrupts are disabled
;when this function is called. */
calla #port_setup_systick
;mov_x &k_next_task,&k_curr_task
;/* Restore the context of the first task that is going to run. */
PORT_RESTORE_CONTEXT
/*-----------------------------------------------------------*/
END