初级会员
- 积分
- 194
- 金钱
- 194
- 注册时间
- 2016-11-3
- 在线时间
- 79 小时
|
楼主 |
发表于 2017-4-22 11:08:57
|
显示全部楼层
[mw_shl_code=applescript,true]//éèÖÃèÎÎñ¶ÑÕ»′óD¡
#define LED_STK_SIZE 64
#define DHT11_STK_SIZE 64
#define BMP180_STK_SIZE 64
#define START_STK_SIZE 512
//éèÖÃèÎÎñóÅÏ輶
#define LED_TASK_Prio 9
#define DHT11_TASK_Prio 5
#define BMP180_TASK_Prio 2
#define START_TASK_Prio 10
//èÎÎñ¶ÑÕ»
OS_STK TASK_LED_STK[LED_STK_SIZE];
OS_STK TASK_DHT11_STK[DHT11_STK_SIZE];
OS_STK TASK_BMP180_STK[BMP180_STK_SIZE];
OS_STK TASK_START_STK[START_STK_SIZE];
//èÎÎñéêÃ÷
void TaskStart(void *pdata);
void TaskLed(void *pdata);
void TaskDht11(void *pdata);
void TaskBmp180(void *pdata);
//Ïμí3ê±ÖóÅäÖÃoˉêy
void SysTick_Configuration(void);
//Mini STM32¿a·¢°åucos·¶ày
//»ùóúucos2.52ÄúoË.
//ÕyμãÔ-×ó@ALIENTEK
//www.openedv.com
//2010.12.15
int main(void)
{
// Stm32_Clock_Init(9); //Ïμí3ê±ÖóéèÖÃ
NVIC_Configuration();
delay_init(72); //Ñóê±3õê¼»ˉ
uart_init(9600); //′®¿ú3õê¼»ˉÎa9600
LED_Init(); //3õê¼»ˉóëLEDᬽóμÄó2¼t½ó¿ú
LCD_Init(); //??? LCD
IIC_PortInit();
POINT_COLOR=RED;//???????
LCD_ShowString(60,50,"WarShip STM32");
LCD_ShowString(60,70,"DHT11 TEST");
LCD_ShowString(60,90,"ATOM@ALIENTEK");
LCD_ShowString(60,110,"2017/4/22");
SysTick_Configuration();
OSInit();
OSTaskCreate( TaskStart, //task pointer
(void *)0, //parameter
(OS_STK *)&TASK_START_STK[START_STK_SIZE-1], //task stack top pointer
START_TASK_Prio ); //task priority
OSStart();
return 0;
}
//¿aê¼èÎÎñ
void TaskStart(void * pdata)
{
pdata = pdata;
OS_ENTER_CRITICAL();
OSTaskCreate(TaskLed, (void * )0, (OS_STK *)&TASK_LED_STK[LED_STK_SIZE-1], LED_TASK_Prio);
OSTaskCreate(TaskDht11, (void * )0, (OS_STK *)&TASK_DHT11_STK[DHT11_STK_SIZE-1], DHT11_TASK_Prio);
OSTaskCreate(TaskBmp180, (void * )0, (OS_STK *)&TASK_BMP180_STK[BMP180_STK_SIZE-1], BMP180_TASK_Prio);
OSTaskSuspend(START_TASK_Prio); //suspend but not delete
OS_EXIT_CRITICAL();
}
//èÎÎñ1
//¿ØÖÆDS0μÄááÃe.
void TaskLed(void *pdata)
{
while(1)
{
// LED0=!LED0;
// OSTimeDlyHMSM(0,0,0,500);
LED1=0;
LED0=1;
delay_ms(500);
LED1=1;
LED0=0;
delay_ms(500);
printf("1\n\n");
}
}
//èÎÎñ2
//¿ØÖÆDS1μÄááÃe.
void TaskDht11(void *pdata)
{
while(1)
{
// LED1=!LED1;
// OSTimeDlyHMSM(0,0,0,200);
u8 temperature;
u8 humidity;
while(DHT11_Init()) //DHT11 ???
{
LCD_ShowString(60,130,"DHT11 Error");
delay_ms(200);
LCD_ShowString(60,150,"Please Check! ");
delay_ms(200);
}
LCD_ShowString(60,130,"DHT11 OK");
POINT_COLOR=BLUE;//???????
LCD_ShowString(60,150,"Temp: C");
LCD_ShowString(60,170,"Humi: %");
DHT11_Read_Data(&temperature,&humidity); //??????
LCD_ShowNum(100,150,temperature,2,16); //????
LCD_ShowNum(100,170,humidity,2,16); //????
delay_ms(1000);
printf("2\n\n");
}
}
void TaskBmp180(void *pdata)
{
while(1)
{
// LED1=!LED1;
// OSTimeDlyHMSM(0,0,0,200);
long UT,UP;
Read_CalibrationData(); //??BMP180?????
BMP180_ID = BMP180_ReadOneByte(0xd0);
POINT_COLOR=BLUE;
LCD_ShowString(60,190,"Press: Pa");
LCD_ShowString(60,210,"Temp1: C");
UT=Get_BMP180UT();
UP=Get_BMP180UP();
Convert_UncompensatedToTrue(UT,UP);
LCD_ShowNum(105,190,True_Press,6,16);
LCD_ShowNum(105,210,True_Temp,2,16);
delay_ms(1000);
printf("3\n\n");
}
}
void SysTick_Configuration(void)
{
SysTick->CTRL&=~(1<<2);//SYSTICKê1óÃía2¿ê±ÖóÔ′
SysTick->CTRL|=1<<1; //¿aÆôSYSTICKÖD¶Ï
SysTick->LOAD=9000; //2úéú1msÖD¶Ï
//bit2Çå¿Õ,Ñ¡Ôñía2¿ê±Öó HCLK/8
SysTick->CTRL|=1<<0;
} |
|