
Program Code - Communication MCU Program
//-------------------------------------------------------------
// Metropolia University of Applied Sciences
// Marcel Mushik 24 April 2011
// Final year project - Electronic class schedule
// Code: Control MCU program
//-------------------------------------------------------------
// Include files ----------------------------------------------
Appendix 2
1(15)
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
// Global variables -------------------------------------------
int i = 0;
int count = 0;
int decision = 0;
// Declarations --------------------------------------
#pragma interrupt_handler Timer8_ISR // timerISR to be handled as the interrupt code
void button_press(void);
// Function description----------------------------------------
// Main function. Receives button selection from user.
// Turns on power to Communications MCU and forwards button selection.
// Waits for a signal indicating that data has been downloaded and written to SD
// card.
// Turns off WiFly, and gives power to Digital photo frame, also enables read.
// Times out, or starts again with another button press.
void main(void)
{
M8C_EnableGInt;
ButtonSig1_Start();
ButtonSig2_Start();
ButtonSig3_Start();
ButtonSig4_Start();
ButtonSig5_Start();
MCU2_pwr_Start();
SD_pwr_Start();
Read_enable_Start();
Timer8_WritePeriod(100);
Timer8_WriteCompareValue(0);
Timer8_EnableInt();
while(1)
{
if ((PRT2DR & 0x01) == 0x01)
{
decision = 1;
button_press();
}
else if ((PRT2DR & 0x04) == 0x04)
{
decision = 2;
button_press();
}
else if ((PRT2DR & 0x10) == 0x10)
{
decision = 3;
button_press();
// Enables Global interrupts
// Makes ready ButtonSig1 for operation
// Makes ready ButtonSig2 for operation
// Makes ready ButtonSig3 for operation
// Makes ready ButtonSig4 for operation
// Makes ready ButtonSig5 for operation
// Makes ready MCU2_pwr for operation
// Makes ready SD_pwr for operation
// Makes ready Read_enable for operation
// Sets timer period value
// Sets timer compare value
// Enables timer interrupts
// Reads input from user.
// Button 1 P2.0
// Notes decision
// Forwards decision to function
// Button 1 P2.2
// Notes decision
// Forwards decision to function
// Button 1 P2.4
// Notes decision
// Forwards decision to function
Comentarios a estos manuales