Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 107 → Rev 109

/Classwork/ECE4534 - Embedded Systems/PIC 27J13/main.c
94,10 → 94,14
pwm_init(); // Initialize the PWM output driver
timers_init(); // Initialize timers
intx_init();
// port_b_int_init(); // Initialze Port B interrupt handler
port_b_int_init(); // Initialze Port B interrupt handler
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
 
// Set all ports as digial I/O
ANCON0 = 0xFF;
ANCON1 = 0x1F;
 
// Configure the hardware i2c device as a slave
#ifdef _MASTER
i2c_configure_master();
105,7 → 109,7
#ifdef _SLAVE
i2c_configure_slave(0x5F);
#endif
 
DBG_PRINT_MAIN("\r\nMain: Program Started\r\n");
 
#ifdef _MASTER
143,10 → 147,10
// Read 2 bytes back
i2c_master_recv(0x5F, 2);
while (i2c_master_busy());
Delay10KTCYx(100);
// Delay10KTCYx(100);
}
#endif
 
// Loop and process recieved messages from interrupts
while (1) {
// Call a routine that blocks until either message queues are not empty
182,7 → 186,7
switch (msgbuffer[0]) {
case 0x2:
length = 1;
msgbuffer[0] = 1; // Size
msgbuffer[0] = 1; // Size
MQ_sendmsg_FromMainToHigh(length, MSGTYPE_I2C_REPLY, (void *) msgbuffer);
break;
case 0x4:
279,28 → 283,28
/* -----------------------------------------------------------*/
/* --- Port B Interrupt Handlers -----------------------------*/
case MSGTYPE_PORTB_4_DOWN:
 
DBG_PRINT_MAIN("Main: Port B4 Down\r\n");
break;
case MSGTYPE_PORTB_4_UP:
 
DBG_PRINT_MAIN("Main: Port B4 Up\r\n");
break;
case MSGTYPE_PORTB_5_DOWN:
 
DBG_PRINT_MAIN("Main: Port B5 Down\r\n");
break;
case MSGTYPE_PORTB_5_UP:
 
DBG_PRINT_MAIN("Main: Port B5 Up\r\n");
break;
case MSGTYPE_PORTB_6_DOWN:
 
DBG_PRINT_MAIN("Main: Port B6 Down\r\n");
break;
case MSGTYPE_PORTB_6_UP:
 
DBG_PRINT_MAIN("Main: Port B6 Up\r\n");
break;
case MSGTYPE_PORTB_7_DOWN:
 
DBG_PRINT_MAIN("Main: Port B7 Down\r\n");
break;
case MSGTYPE_PORTB_7_UP:
 
DBG_PRINT_MAIN("Main: Port B7 Up\r\n");
break;
/* -----------------------------------------------------------*/
default: