/* --COPYRIGHT--,BSD * Copyright (c) 2015, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * --/COPYRIGHT--*/ //*************************************************************************************** // Blink the LED Demo - Software Toggle P1.0 // // Description; Toggle P1.0 inside of a software loop. // ACLK = n/a, MCLK = SMCLK = default DCO // // MSP432P4xx // ----------------- // /|\| XIN|- // | | | // --|RST XOUT|- // | | // | P1.0|-->LED // // E. Chen // Texas Instruments, Inc // March 2015 // Built with Code Composer Studio v6 //*************************************************************************************** #include #include "cmsis_os.h" #define APPLICATION_TASK_STK_SIZE 256 extern void application_entry(void *arg); osThreadDef(application_entry, osPriorityNormal, 1, APPLICATION_TASK_STK_SIZE); #define TASK1_STK_SIZE 128 void task1(void *arg); osThreadDef(task1, osPriorityNormal, 1, TASK1_STK_SIZE); #define TASK2_STK_SIZE 128 void task2(void *arg); osThreadDef(task2, osPriorityNormal, 1, TASK2_STK_SIZE); void SysTick_Handler(void) { if(tos_knl_is_running()) { tos_knl_irq_enter(); tos_tick_handler(); tos_knl_irq_leave(); } } void board_init(void) { WDT_A_hold(WDT_A_BASE); SysTick_registerInterrupt(SysTick_Handler); SysTick_setPeriod(SystemCoreClock / 1000U); SysTick_enableInterrupt(); SysTick_enableModule(); // Set P1.0 to output direction GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN0); GPIO_setAsOutputPin(GPIO_PORT_P2,GPIO_PIN0); GPIO_setAsOutputPin(GPIO_PORT_P2,GPIO_PIN1); GPIO_setAsOutputPin(GPIO_PORT_P2,GPIO_PIN2); } void task1(void *arg) { //int count = 1; while (1) { GPIO_toggleOutputOnPin(GPIO_PORT_P1,GPIO_PIN0); //printf("###This is task1, %d\r\n", count++); osDelay(2000); } } void task2(void *arg) { //int count = 1; while (1) { //printf("***This is task2, %d\r\n", count++); GPIO_toggleOutputOnPin(GPIO_PORT_P2,GPIO_PIN0); osDelay(1000); } } void application_entry(void *arg) { osThreadCreate(osThread(task1), NULL); // Create task1 osThreadCreate(osThread(task2), NULL); // Create task2 } int main(void) { board_init(); //printf("Welcome to TencentOS tiny\r\n"); osKernelInitialize(); osThreadCreate(osThread(application_entry), NULL); osKernelStart(); }