/* * File : main.c * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Change Logs: * Date Author Notes * 2018-08-16 armink first implementation */ #include #include //#include "stackdepth.h" #define LED_PIN 3 #define THREAD_STACK_SIZE 2048 #define THREAD_PRIORITY 3 #define THREAD_TIMESLICE 200 void thread3_entry(void* param); int main(void) { rt_thread_t thread2 = rt_thread_create( "Thread3", thread3_entry, RT_NULL, THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE); return 0; } void thread3_entry(void* param) { while(1) { } } register unsigned int *_psp __asm("psp"); unsigned int *getsp() { unsigned int *p =NULL; p = _psp; return p; } int add(int i, int j) { int res = 0; __asm ( "ADD res, i, j \t\n" ); //res = i+j; return res; } int led(void) { int a = 1; int b = 2; int c = 0; unsigned int *ppp = NULL; rt_uint8_t count; rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT); for(count = 0 ; count < 10 ;count++) { rt_pin_write(LED_PIN, PIN_HIGH); //rt_kprintf("led on, count : %d\r\n", count); //rt_thread_mdelay(500); rt_thread_mdelay(50); rt_pin_write(LED_PIN, PIN_LOW); //rt_kprintf("led off\r\n"); //rt_thread_mdelay(500); rt_thread_mdelay(50); } c = add(a,b); ppp = getsp(); c = *ppp; rt_kprintf("c value : %d\r\n", c); return c; } MSH_CMD_EXPORT(led, RT-Thread first led sample);