⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 zigbee 飞思卡尔 音频传输 基于ucos的所有源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************
www.hhcn.org
www.hhcn.com
author:michael.chen     email:mingzhixx@gmail.com
time:2006.05.17
revision:1.0
******************************************************/


/*
 * File:		main.c
 * Purpose:		Main process
 *
 */

/* 
 * Include the generic CPU header file 
 */
#include "mcf5xxx.h"

/* 
 * Include the specific CPU header file 
 */
#include "mcf5213.h"

/* 
 * Include the board specific header file 
 */
#if (defined(M5213EVB))
#include "m5213evb/m5213evb.h"
#elif (defined(M5211DEMO))
#include "m5211demo/m5211demo.h"
#elif (defined(M5213P))
#include "m5213p/m5213p.h"
#else
#error "No valid platform defined"
#endif

/* 
 * Include any toolchain specfic header files 
 */
#if (defined(__MWERKS__))
#include "build/mwerks/mwerks.h"
#elif (defined(__DCC__))
#include "build/wrs/diab.h"
#elif (defined(__ghs__))
#include "build/ghs/ghs.h"
#endif

/* 
 * Include common utilities
 */
#include "assert.h"
#include "io.h"
//#include "stdlib.h"

/*************************************************
HHCF521X-KIRIN-R1
****************************************************/
#include "src/drivers/button/button.h"
#include "../drivers/led/led.h"
#include "../drivers/pwm/Pwm_Module.h"
#include "../drivers/rs485/rs485.h"
#include "../drivers/uart2/uart2.h"
#include "../drivers/audio/Adc_Pwm_Module.h"
#include "../drivers/I2C/i2c.h"
#include "../drivers/FlexCAN/FlexCAN.h"
#include "../drivers/zigbee audio demo/zigbee demo.h"

/*
variable for button which are defined in button.c
*/
extern vint32 button_value;//the value of button by pressed
extern vint32 button_flag;//the times of button by pressed
extern vuint8 button_value_current;//the value of button by pressed currently
/*
*********************************************************************************************************
*                                               uC/OS-II
*                                         The Real-Time Kernel
*
*                             (c) Copyright 2000, Jean J. Labrosse, Weston, FL
*                                          All Rights Reserved
*
*                                          MCF5282 Sample code
*
*
*
* File         : MAIN.C
* Originally by: Jean J. Labrosse
* Modified by  : Mark D. Medonis
* Modified by  : Carlton Heyer for CF5282
*********************************************************************************************************
*/

#include "INCLUDES.H"

#define	TASK_WORK	100
#define	APP_START_TASK_LED	1
#define	APP_TASK_1_LED		2
#define	APP_TASK_2_LED		4

/*
*********************************************************************************************************
*                                           REVISION HISTORY
*
*
* 0.a
* Port for Motorola MCF5272 ColdFire microprocessor.
* Added some printf statements to the AppTasks to monitor multitasking. This
* is used with the BDM debugger and the console I/O libraries provided by CodeWarrior.
* M. Medonis 4/16/2002
*
* Commented out printf statements in the Tasks because they were causing errors.
* Added code to blink LEDs for the Avnet Coldfire board (5282 based).
* Modified for 5282 timer0.
* Carlton Heyer 4/28/04
*      
*********************************************************************************************************
*/


/*$PAGE*/
/*
*********************************************************************************************************
*                                                VARIABLES
*********************************************************************************************************
*/

OS_STK  AppStartTaskStk[256];
//OS_STK  AppTask1Stk[256];
//OS_STK  AppTask2Stk[256];

INT8U leds = 0xff;				// Assume all LEDs are lit
INT8U led_ptr = 0x80;			// Point to LED7

/*
*********************************************************************************************************
*                                            FUNCTION PROTOTYPES
*********************************************************************************************************
*/

static void  AppStartTask(void *pdata);
//static void  AppTask1(void *pdata);
//static void  AppTask2(void *pdata);
static void  AppTickInit(void);

//void gpt_init();
//void led_toggle(INT8U);
//void led_enable(INT8U);
//void led_disable(INT8U);
void isr_init(void);
//INT8U get_sw(void);

extern void timer0_handler(void);

void menu(void);



/*
*********************************************************************************************************
*                                                main()
*
* Description : This is the standard entry point for C code.  It is assumed that your code will call
*               main() once you have performed all necessary 683xx and C initialization.
* Arguments   : none
*********************************************************************************************************
*/

void main (void)
{
    /* Enable signals as GPIO */
    MCF_GPIO_PTCPAR = 0
        | MCF_GPIO_PTCPAR_TIN3_GPIO
        | MCF_GPIO_PTCPAR_TIN2_GPIO
        | MCF_GPIO_PTCPAR_TIN1_GPIO
        | MCF_GPIO_PTCPAR_TIN0_GPIO;
    
    /* Set output values */
    MCF_GPIO_PORTTC = 0x0F;
    
    /* Enable signals as digital outputs */
    MCF_GPIO_DDRTC = 0
        | MCF_GPIO_DDRTC_DDRTC3
        | MCF_GPIO_DDRTC_DDRTC2
        | MCF_GPIO_DDRTC_DDRTC1
        | MCF_GPIO_DDRTC_DDRTC0;
    printf("\nWelcome to use HHCF521X-KIRIN-R1\n");
    printf("					www.hhcn.org www.hhcn.com\n");
	printf("\n\nStart uCOS-II on MCF5213 doggle board.\n\n");
    InitVBR();
	// Init int vectors to default routine
	isr_init();
    
    OSVectSet(47, (void (*)(void))OSCtxSw); /* Setup the context switch exception                      */

    /*---- Any initialization code prior to calling OSInit() goes HERE --------------------------------*/
   
    OSInit();                               /* Initialize "uC/OS-II, The Real-Time Kernel"             */

    /*---- Any initialization code before starting multitasking ---------------------------------------*/

    OSTaskCreate(AppStartTask, (void *)0x12345678L, (void *)&AppStartTaskStk[255], 0);

    /*---- Create any other task you want before we start multitasking --------------------------------*/

    OSStart();                              /* Start multitasking (i.e. give control to uC/OS-II)      */
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                          STARTUP TASK
*
* Description : This is an example of a startup task.  As mentioned in the book's text, you MUST
*               initialize the ticker only once multitasking has started.
* Arguments   : pdata   is the argument passed to 'AppStartTask()' by 'OSTaskCreate()'.
* Notes       : 1) The first line of code is used to prevent a compiler warning because 'pdata' is not
*                  used.  The compiler should not generate any code for this statement.
*               2) Interrupts are enabled once the task start because the I-bit of the CCR register was
*                  set to 0 by 'OSTaskCreate()'.
*********************************************************************************************************

comment:打印菜单,用户根据按钮来选择加载不同的演示程序。
		调用menu()来实现。
*/

static void  AppStartTask (void *pdata)
{
  	INT32U i=0;								// Task counter
  	INT32U work;
    pdata = pdata;                          /* 'pdata' should contain 0x12345678!                      */

    AppTickInit();                          /* Initialize the ticker                                   */

/*****************************************************
 start	menu
****************************************************/
	menu();
  
    while (TRUE) {                          /* Task body, always written as an infinite loop.          */
        /*---- Task code goes HERE! -------------------------------------------------------------------*/
		i++;
		//comment by michael chen
		//led_toggle(APP_START_TASK_LED);
//        printf("Start %i\r\n", i);	// printf statements cause runtime errors

		// Have the task pretend to do some work
        work = 5 * TASK_WORK;
        while(work--);			// App Start Task work
        
        OSTimeDly(3000);                       /* Delay task execution for one clock tick                 */
    }
}
/*
*********************************************************************************************************
*                                       TICKER INITIALIZATION
*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -