嵌入式系统设计实验报告

{ direction = 0;

}

}

}

void Direction_change(void *pdata) { uint8 error; int floor_temp; int up, down;

pdata = pdata;

TargetInit (); //目标板初始化

direction = 0; while (1) {

OSFlagPend(direct_chan,

0x03,

OS_FLAG_WAIT_SET_ALL

OS_FLAG_CONSUME, 0, &error); //接收事件标志组发送的消息 if (direction == 1) {

for

(floor_temp

=

current_floor

+

1;

floor_temp

<=

&& !semaphore[floor_temp]; floor_temp++);

if (floor_temp == 7) //如果楼层已到达顶层时,改变方向向下运行

{ direction = -1;

}

}

else if (direction == -1) {

for

(floor_temp

=

current_floor

-

1;

floor_temp

>=

&& !semaphore[floor_temp]; floor_temp--);

if (floor_temp == 0) //如果楼层已到达底层时,改变方向向上运行

+

6

1

{

}

else if (direction == 0)

is_working = 1;

OSTimeDly(OS_TICKS_PER_SEC); is_working = 0; if (work_count == 1) } else {

if (current_floor == 1) }

else if (current_floor == 6) } else

for

(floor_temp

=

current_floor

+

1;

floor_temp

<=

6

direction = -1; direction = 1;

for (floor_temp = 1; floor_temp <= 6 && !semaphore[floor_temp]; if (current_floor > floor_temp) } else }

direction = 1; direction = -1;

}

direction = 1;

{

{ floor_temp++); {

{

{

{

{

&& !semaphore[floor_temp]; floor_temp++);

up = floor_temp; for

(floor_temp

=

current_floor

-

1;

floor_temp

>=

1

&& !semaphore[floor_temp]; floor_temp--);

down = floor_temp;

if (up - current_floor > current_floor - down) //首先响应距离较近的

楼层

{ }

void Up_down(void *pdata) {

int count; uint8 error; }

}

OSSemPost(u_d);

}

}

}

else if (up - current_floor < current_floor - down) } else { }

if (6 - current_floor > current_floor - 1) }

else if (6 - current_floor < current_floor - 1) } }

direction = 1;

direction = 1; direction = -1; direction = 1; direction = -1;

{

{

{

else {

pdata = pdata;

TargetInit (); //目标板初始化 current_floor = 1;

MSPI_SendData(DISP_TAB[current_floor]); IO1CLR = 1 << 18; //使第一个流水灯点亮

OSFlagPost(direct_chan, 0x01, OS_FLAG_SET, &error);

while (1) {

OSSemPend(u_d, 0, &error); //接收信号量 OSTimeDly(OS_TICKS_PER_SEC); //延时

IO1SET = 1 << (17 + current_floor); //将当前楼层灯熄灭 if (direction == 1) }

else if (direction == -1) { }

IO1CLR = 1 << (17 + current_floor); //使当前楼层灯点亮

MSPI_SendData(DISP_TAB[current_floor]); //向数码管发送楼层消息 if (semaphore[current_floor] == 1) }

count = 3;

while (count) //到达目标楼层后灯闪三下 }

work_count--;

semaphore[current_floor] = 0; //信号量还原为0

OSTimeDly(OS_TICKS_PER_SEC / 2); IO1SET = 1 << (17 + current_floor); / OSTimeDly(OS_TICKS_PER_SEC / 2); IO1CLR |= 1 << (17 + current_floor); count--; current_floor--; current_floor++;

{

{

{

OSFlagPost(direct_chan, 0x01, OS_FLAG_SET, &error);

}

}

基于lpc2131的模拟MP3播放器实验

一、实验目的

6、熟悉ARM & ADS V1.2 的环境 7、理解LPC2131芯片引脚功能的选择 8、理解GPIO的使用设置、输入驱动方法

9、理解PWM的通信原理,学习ARM PWM资源的通信编程 10、学习在LPC2131上移植ucosⅡ系统 二、实验内容及要求

(1)通过键盘输入,进入MP3播放器相应的功能选项。

(2)MP3播放器具备的功能选项为:播放、暂停、停止、音量控制、音乐下载。

(3)MP3播放器响应进入各功能状态时,蜂鸣器蜂鸣。 (4)流水灯表示MP3播放器当前所处的功能状态。

(5)蜂鸣器蜂鸣声音的大小代表音量的大小,音量控制状态和音乐

下载状态可分别与其他3种状态同事存在。

(6)数码管数字大小表示执行MP3各功能状态的时间。 三、系统总体设计(总体方案及系统框图)

系统主要创建了六个任务,分别为MP3总任务、判断按键任务、播放音乐任务、控制音量任务、播放上一曲或下一曲任务及暂停或停止任务,然后启动多任务环境,通过创建的消息邮箱发送并接收消息,进而实现MP3播放的一些简单功能。

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4