亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? usage.dox

?? yavrtos,一款用于廣泛用于AVR單片機(jī)的RTOS,文件里是這款OS的源碼
?? DOX
字號(hào):
/**

\page usage Using YAVRTOS

\li \subpage usage-sema
\li \subpage usage-mbox
\li \subpage usage-mutex

\page usage-sema Using semaphores

Semaphores are used to send signals between tasks, or between tasks and ISRs.

\section usage-sema-1 Example 1 - signalling between tasks

\code
semaphore_t sema;

void semaphore_receiving_task(void *p) {
	while (1) {
		wait_for_increment_of(&sema, 1);
		do_stuff();
	}
}

void semaphore_writing_task(void *p) {
	while (1) {
		wait_for_conditions_to_be_right();
		increment_semaphore_by(&sema, 1); // This makes the "wait_for_increment_of()" function in the receiving task return
	}
}
\endcode
In the above example, if the \c semaphore_receiving_task is of higher priority than the \c semaphore_writing_task, then as
soon as the increment_semaphore_by() call is made, the \c semaphore_receiving_task will start executing.

\section usage-sema-2 Example 2 - signalling tasks from an ISR

The classic use of semaphores is to provide tasks with an easy means of implementing a delay. This is done by having a semaphore
increment during the tick - then tasks can use that semaphore's value to suspend themselves for a known period of time.
\code
semaphore_t tick;

// This is a function that runs every tick - we use it to increment the tick semaphore value by one
uint8_t tick_interrupt() {
        increment_semaphore_by(&tick, 1);
        return 1;
}

// e.g. the TIMER1_COMPA interrupt is our tick interrupt
TASK_ISR(TIMER1_COMPA_vect, tick_interrupt())

// This task needs to periodically delay by 100 ticks
void periodical_task(void *p) {
	while (1) {
		...
		wait_for_increment_of(&tick, 100); // This function call won't return until 100 ticks have elapsed
		...
	}
}
\endcode

\page usage-mbox Using mailboxes

Mailboxes are used to send data between tasks or between ISRs and tasks.

\section usage-mbox-1 Example 1 - distributing data throughout the application

In this example, we have a task that generates information to be used by other parts of the application

\code
mailbox_t data_mbox;

void get_and_post_data();

void data_consumer_1_task(void *p) {
	int16_t version;
	int *data;
	...
	version = get_current_mbox_version(&data_mbox);
	while (1) {
		if ((data = (int *)read_mbox_min_version(&data_mbox, &version)) != 0) {
			do_something_with_the_data(*data);
		}
		release_mbox_read();
		version++;
	}
}

void data_consumer_2_task(void *p) {
	int16_t version;
	int *data;
	...
	version = get_current_mbox_version(&data_mbox);
	while (1) {
		if ((data = (int *)read_mbox_min_version(&data_mbox, &version)) != 0) {
			do_something_else_with_the_data(*data);
		}
		release_mbox_read();
		version++;
	}
}

void data_producer_task(void *p) {
	...
	while (1) {
		...
		get_and_post_data();
		...
	}
}

void get_and_post_data() {
	int the_data = get_data_from_some_microcontroller_system();
	write_mbox(&data_mbox, &the_data, 0, 2); // See below...
}

int main() {
	...
	initialise_mbox(&data_mbox, 0, 0);
	...
}
\endcode

So the big question is - what do the two final parameters of write_mbox() mean?

The first parameter is the number of reading tasks to wait for. In this case, we decide that we do not wish to wait for
any reading task - if there are no tasks waiting to read from the mailbox (i.e. no tasks have suspended themselves on
read_mbox_min_version()), then the data will end up being "lost". It is up to the application developer to decide how
many tasks, if any, \b must receive the data.

The second parameter means that, once the data has been put into the mailbox, the \c data_producer_task will be suspended
until all of the tasks that were suspended on read_mbox_min_version() have received the data and have called release_mbox_read().
It also means that, once all the receiving tasks have called release_mbox_read(), the mailbox will contain a new version with
a null pointer. This means that the \c data_producer_task is guaranteed that no-one is going to subsequently try and read the
\c the_data which is important, as \c the_data is a local variable and hence ceases to exist once \c get_and_post_data() returns.

\section usage-mbox-2 Example 2 - sending commands to a task

In this example, we will send commands to a task that controls an LED display.

\code
// This structure contains an instruction for our lcd display driver task
typedef struct lcd_command_struct {
	uint8_t command; // e.g. cursor on, clear display
	char string[21]; // e.g. a string to display
	...
} lcd_command_t;

// The mailbox that will be used to send instructions to the lcd display driver task
mailbox_t lcd_commands_mbox;

// The lcd display driver task
void lcd_display_driver_task(void *p) {
	lcd_command_t *cmd;
	int16_t version;
	initialise_lcd_display();
	version = get_current_mbox_version(&lcd_commands_mbox);
	while (1) {
		// When we set up the mailbox with initialise_mbox(), we set it up with null data, so our first read is going to return null
		if ((cmd = (lcd_command_t *)read_mbox_min_version(&lcd_commands_mbox, &version)) != 0) {
			process_lcd_command(cmd);
		}
		release_mbox_read();
		version++;
	}
}

// A task that wants to send something to the LCD
void data_provider_task(void *p) {
	lcd_command_t cmd;
	while (1) {
		get_information_for_lcd(&cmd);
		write_mbox(&lcd_commands_mbox, &cmd, 1, 1); // see below...
	}
}

int main() {
	...
	initialise_mbox(&lcd_commands_mbox, 0, 0);
	...
}
\endcode
So how do we choose the value for the last two arguments in write_mbox()? Assuming that the \c lcd_display_driver_task is of
lower priority, we need to ensure that it has a chance to initialise the LCD display before we start sending commands to
it - so we want it to get to the stage of being suspended on the read_mailbox_min_version() call. The way to do this is
by using a value of 1 for the \c wait_for_receivers argument of write_mbox().

Also, we don't want the \c data_provider_task to make another call to get_information_for_lcd() until the \c lcd_display_driver_task
has finished reading the command we have just sent it (otherwise, get_information_for_lcd() could over-write the information
held in the \c lcd_command before the \c lcd_display_driver_task has finished with it). By providing a value of one for the
\c wait_for_empty_nullify argument of write_mbox(), we ensure that write_mbox() won't return until the \c lcd_display_driver_task has
executed release_mbox_read().

In this case, there is no need to "nullify" the mailbox after it has been read, because we know that no other task is going to
attempt to read it again.

Of course, there is nothing to stop other tasks from using the \c lcd_commands_mbox - the mailbox is, in effect, a software interface
to your LCD that any task can call upon at any time.

\section usage-mbox-3 Example 3 - sending data from an ISR to a task

Sending information from ISRs to tasks is slightly complicated by the fact that ISRs cannot be suspended, hence they must use
the write_mbox_now() call, which will fail if the mailbox is in use by a task. Hence all tasks that read from the mailbox should
probably be of high priority, and should call release_mbox_read() before the next interrupt.

\code
// We cannot use a local variable to hold the ISR data, as the data still needs to exist when the ISR exits
int isr_data;

mailbox_t isr_data_mbox;

uint8_t isr() {
	isr_data = read_data_from_some_microcontroller_system();
	write_mbox_now(&isr_data_mbox, &isr_data);
	return 1; // We have (probably) affected a mailbox, so the task switcher needs to run
}

TASK_ISR(xxxx_vect, isr())

void data_reading_task(void *p) {
	int isr_data_local_copy;
	int *i;
	int16_t version = get_current_mbox_version(&isr_data_mbox);
	while (1) {
		if ((i = (int *)read_mbox_min_version(&isr_data_mbox, &version)) != 0) {
			isr_data_local_copy = *i; // Quickly retrieve the data!
			release_mbox_read(); // The mailbox is now available to the ISR again
			process_data(isr_data_local_copy);
		} else {
			release_mbox_read(); // A good idea to always call this after any attempt to read a mailbox...
		}
		version++;
	}
}

int main() {
	...
	initialise_mbox(&isr_data_mbox, 0, 0);
	...
}
\endcode


\page usage-mutex Using mutexes

A mutex is used to ensure that only one task is using a shared resource at any one time.

\section usage-mutex-1 Example - sharing I/O pins

Given that microcontrollers only have a limited number of I/O pins, it is common for pins to be dual-purpose.

\code
mutex_t pin_mutex;

void task1(void *p) {
	...
	// task 1 now needs to use the dual-purpose pins
	lock_on(&pin_mutex);
	// we now "own" the mutex, so we "own" the pins
	do_stuff_with_the_dual_purpose_pins();
	// release the pins
	lock_off(&pin_mutex);
	...
}

void task2(void *p) {
	...
	// task 2 now needs to use the dual-purpose pins
	lock_on(&pin_mutex);
	// we now "own" the mutex, so we "own" the pins
	do_other_stuff_with_the_dual_purpose_pins();
	// release the pins
	lock_off(&pin_mutex);
	...
}
\endcode

*/

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产123| 日韩一区二区三免费高清| 欧美激情在线一区二区三区| 国产乱码精品一区二区三区av | 国产精品网站在线| 成人中文字幕合集| 日韩伦理免费电影| 在线免费观看一区| 日本欧美大码aⅴ在线播放| 日韩午夜激情av| 国产夫妻精品视频| 亚洲精品视频在线| 91精品国产欧美一区二区18| 国内精品免费**视频| 中文字幕一区二区三区不卡在线| 色综合中文字幕国产 | 91在线精品一区二区三区| 一区二区三区久久| 日韩欧美在线1卡| 高清国产一区二区| 亚洲综合视频网| 欧美一区二区三区喷汁尤物| 国产最新精品精品你懂的| 国产精品欧美综合在线| 日本电影亚洲天堂一区| 蜜桃视频在线观看一区二区| 国产精品美女久久久久久久久久久 | 黄页视频在线91| 成人欧美一区二区三区| 这里只有精品视频在线观看| 国产a精品视频| 日韩精品午夜视频| 国产精品久久久久久久久图文区| 欧美三级日韩在线| 成人精品国产一区二区4080| 午夜免费久久看| 中文乱码免费一区二区| 欧美精品丝袜中出| 97超碰欧美中文字幕| 久久精品国产99久久6| 亚洲欧美日韩综合aⅴ视频| 精品免费日韩av| 欧美日韩免费电影| 99久久精品免费看国产| 国产原创一区二区| 日韩av在线免费观看不卡| 亚洲免费观看高清完整版在线观看熊| 日韩免费成人网| 欧美日韩精品福利| 91色|porny| 高清不卡在线观看av| 久久99久国产精品黄毛片色诱| 亚洲一区av在线| 国产精品久久三| 国产午夜亚洲精品不卡| 日韩视频不卡中文| 制服丝袜激情欧洲亚洲| 欧美午夜在线一二页| 97se亚洲国产综合在线| 成人黄色电影在线| 国产成人综合在线| 极品少妇xxxx精品少妇| 轻轻草成人在线| 日本在线观看不卡视频| 亚洲成av人片| 亚洲成a人v欧美综合天堂下载| 亚洲精品国产无套在线观 | 亚洲欧美日韩在线| 国产欧美精品区一区二区三区| 欧美videofree性高清杂交| 欧美精选午夜久久久乱码6080| 在线精品国精品国产尤物884a| 91网站黄www| 91小视频在线| 色菇凉天天综合网| 在线视频综合导航| 精品视频在线免费观看| 欧美三级蜜桃2在线观看| 欧美三级中文字| 欧美一区二区三区免费| 欧美一区二区三区在线观看视频| 欧美高清视频不卡网| 欧美一区二区三区四区五区| 67194成人在线观看| 91精品国产乱码久久蜜臀| 欧美福利视频一区| 欧美成人一区二区三区在线观看| 日韩视频免费观看高清完整版在线观看 | 男男视频亚洲欧美| 九九精品一区二区| 国产999精品久久久久久绿帽| 国产mv日韩mv欧美| 91色porny蝌蚪| 欧美老女人第四色| 2020国产精品久久精品美国| 亚洲国产精品国自产拍av| 1000精品久久久久久久久| 亚洲精品国产成人久久av盗摄| 亚洲国产精品久久艾草纯爱| 日韩综合小视频| 国产乱码精品一区二区三区五月婷| 丰满白嫩尤物一区二区| 色婷婷av一区二区| 欧美一级在线观看| 中文字幕 久热精品 视频在线 | 成人黄动漫网站免费app| 色999日韩国产欧美一区二区| 欧美喷潮久久久xxxxx| 久久美女高清视频| 亚洲精品老司机| 极品尤物av久久免费看| 99re热这里只有精品视频| 在线观看91av| 欧美国产精品一区二区| 午夜精品影院在线观看| 国产成人av影院| 在线一区二区三区四区| 亚洲精品一区二区三区香蕉| 亚洲丝袜自拍清纯另类| 蜜臀久久久久久久| 99久久夜色精品国产网站| 欧美精品久久久久久久多人混战 | 欧美性做爰猛烈叫床潮| 精品999在线播放| 亚洲影院理伦片| 国内成人免费视频| 欧美日韩中字一区| 中文字幕制服丝袜一区二区三区| 天天综合日日夜夜精品| 99热在这里有精品免费| 日韩免费观看高清完整版在线观看 | 91免费版在线看| 日韩欧美一级精品久久| 亚洲丝袜另类动漫二区| 国产一区二区三区电影在线观看| 欧美视频完全免费看| 日本一区二区三区电影| 三级久久三级久久| 91黄色小视频| 国产色91在线| 精品中文字幕一区二区| 欧美日韩午夜在线视频| 亚洲男人都懂的| 国产不卡一区视频| 日韩精品中文字幕在线不卡尤物| 一区二区高清在线| 99re在线视频这里只有精品| 久久久久久电影| 精品无人区卡一卡二卡三乱码免费卡 | 久久精品72免费观看| 欧美日韩精品是欧美日韩精品| 中文字幕一区二区三区乱码在线| 国产一区欧美一区| 欧美成人一区二区三区在线观看| 日韩精品亚洲专区| 欧美肥大bbwbbw高潮| 亚洲国产一二三| 欧美无砖专区一中文字| 一区二区在线看| 一本到不卡免费一区二区| 日韩理论片网站| 成+人+亚洲+综合天堂| 国产精品无人区| 成人动漫一区二区在线| 中文字幕在线一区免费| a在线播放不卡| 中文字幕av在线一区二区三区| 国产成人精品免费看| 日本一区二区三区免费乱视频 | 色综合久久88色综合天天免费| 国产精品国产三级国产普通话蜜臀| 国产a精品视频| 亚洲欧洲性图库| 色婷婷国产精品综合在线观看| 一区二区三区影院| 欧美午夜理伦三级在线观看| 亚洲成年人影院| 日韩一区二区影院| 激情深爱一区二区| 国产女同互慰高潮91漫画| av一区二区三区在线| 亚洲免费观看高清在线观看| 欧美午夜在线一二页| 天堂午夜影视日韩欧美一区二区| 67194成人在线观看| 国产一区 二区| 国产精品视频第一区| 日本久久电影网| 日韩精品欧美成人高清一区二区| 91精品国产欧美一区二区18| 黄色精品一二区| 中文字幕日本乱码精品影院| 欧美自拍偷拍午夜视频| 男女性色大片免费观看一区二区| 亚洲精品在线观看网站| 懂色av一区二区三区蜜臀| 亚洲精品视频一区| 欧美一级片免费看| 成人av资源下载| 香蕉影视欧美成人|