📄 4avros_tasks.c
字号:
//---------------------------------------------------------------------------------------------------------//
// __ __ ___ ____ _____ //
// / // / / |_ _______/ __ \/ ___/ //
// / // /_/ /| | | / / ___/ / / /\__ \ //
// /__ __/ ___ | |/ / / / /_/ /___/ / //
// /_/ /_/ |_|___/_/ \____//____/ //
// ____ ____ _ _ _ //
// / ___|___ ___ _ __ / ___| ___| |__ ___ __| |_ _| | ___ _ __ //
// | | / _ \ / _ \| '_ \ \___ \ / __| '_ \ / _ \/ _` | | | | |/ _ \ '__| //
// | |__| (_) | (_) | |_) | ___) | (__| | | | __/ (_| | |_| | | __/ | //
// \____\___/ \___/| .__/ |____/ \___|_| |_|\___|\__,_|\__,_|_|\___|_| //
// |_| //
// __ __ //
// / / __ __ ______ ______/ /__ ____ _ //
// / _ \/ // / / __/ // / __/ __/ |/ / ' \ //
// /_.__/\_, / \__/\_,_/_/ \__/|___/_/_/_/ //
// /___/ //
// //
// //
// Copyright 2007 by Curt Van Maanen //
// //
// Version 2007.10.06 //
//---------------------------------------------------------------------------------------------------------//
// 4AvrOS_Tasks.c //
//---------------------------------------------------------------------------------------------------------//
/*-----------------------------------------------------------------------------------------------------------
___ _ _ ___ _ _ _ ___ ___ ___
|_ _| \| |/ __| | | | | | \| __/ __|
| || .` | (__| |_| |_| | |) | _|\__ \
|___|_|\_|\___|____\___/|___/|___|___/
-----------------------------------------------------------------------------------------------------------*/
#include <avr/io.h>
#include "4AvrOS_Tasks.h" // needs to be before 4AvrOS.h
#include "4AvrOS.h"
/*-----------------------------------------------------------------------------------------------------------
___ ___ ___ ___ _ _ ___ ___
| \| __| __|_ _| \| | __/ __|
| |) | _|| _| | || .` | _|\__ \
|___/|___|_| |___|_|\_|___|___/
-----------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------
___ _ ___ ___ _ _ __ ___ ___ ___ _ ___ _ ___ ___
/ __| | / _ \| _ ) /_\ | | \ \ / /_\ | _ \_ _| /_\ | _ ) | | __/ __|
| (_ | |_| (_) | _ \/ _ \| |__ \ V / _ \| /| | / _ \| _ \ |__| _|\__ \
\___|____\___/|___/_/ \_\____| \_/_/ \_\_|_\___/_/ \_\___/____|___|___/
-----------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------
___ _ _ _ _ ___ _____ ___ ___ _ _ ___
| __| | | | \| |/ __|_ _|_ _/ _ \| \| |/ __|
| _|| |_| | .` | (__ | | | | (_) | .` |\__ \
|_| \___/|_|\_|\___| |_| |___\___/|_|\_||___/
-----------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------
initialize ports, registers, etc. called from main()
-----------------------------------------------------------------------------------------------------------*/
void init_mystuff(void){
DDRB |= ((1<<PB0) | (1<<PB1)); //pb0,pb1 output for led
}
/*-----------------------------------------------------------------------------------------------------------
___ _ _ _____ ___ ___ ___ _ _ ___ _____ ___
|_ _| \| |_ _| __| _ \ _ \ | | | _ \_ _/ __|
| || .` | | | | _|| / / |_| | _/ | | \__ \
|___|_|\_| |_| |___|_|_\_|_\\___/|_| |_| |___/
-----------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------
_____ _ ___ _ _____
|_ _/_\ / __| |/ / __|
| |/ _ \\__ \ ' <\__ \
|_/_/ \_\___/_|\_\___/
-------------------------------------------------------------------------------------------------------------
tasks
BEGIN(taskname)
//code here
//make sure an os call is in here somewhere, else will be stuck here
END_TASK
-----------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------
demoLed1_Task
-----------------------------------------------------------------------------------------------------------*/
BEGIN_TASK(demoLed1_Task) // flash led on PB0
osWAIT(100); // wait 1s
PORTB ^= (1<<PB0); // invert led
END_TASK
/*-----------------------------------------------------------------------------------------------------------
demoLed2_Task
-----------------------------------------------------------------------------------------------------------*/
BEGIN_TASK(demoLed2_Task) // flash led on PB0
static uint8_t i;
for(i=1; i<15; i++){
osWAIT(i); // wait
PORTB ^= (1<<PB1); // invert led
}
END_TASK
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -