100,6 → 100,7 |
OSCTUNEbits.PLLEN = 1; // Enable 4x PLL |
OSCCONbits.IRCF = 0b111; // Set INTOSC postscaler to 8MHz |
OSCCONbits.SCS = 0b00; // Use PLL as primary clock source |
OSCCONbits.IDLEN = 1; // Set CPU to IDLE on sleep instruction |
/* -------------------------------------------------------------------- */ |
|
// Set all ports as digial I/O |
192,7 → 193,6 |
buffer_read(i2c_last_req_size, msgbuffer); |
DBG_PRINT_MAIN("Main: (I2C Return 0x4) Returning %d bytes\r\n", i2c_last_req_size); |
MQ_sendmsg_FromMainToHigh(i2c_last_req_size, MSGTYPE_I2C_REPLY, (void *) msgbuffer); |
pwm_LED_off(); // Turn off LED if it was on |
break; |
case 0x6: |
// Return status of IR signal input |
392,7 → 392,7 |
} |
|
// Send value of first byte received to LED display |
led_driver_num(frame_data_packet->data[0]); |
// led_driver_num(frame_data_packet->data[0]); |
#endif |
#ifdef _REMOTE |
led_driver_num(frame_data_packet->data[0]); |
505,16 → 505,6 |
} |
} else { |
switch (msgtype) { |
case MSGTYPE_INT1: |
#ifdef _BASE_STATION |
wake(); |
IR_receive_flag = 1; |
pwm_LED_on(); |
// timer2_enable(); // Enable timer 2 to turn off LED |
sleep(); |
// DBG_PRINT_MAIN("Main: INT1 Interrupt\r\n"); |
#endif |
break; |
/* --- Port B Interrupt Handlers -----------------------------*/ |
case MSGTYPE_PORTB_4_DOWN: |
DBG_PRINT_MAIN("Main: Port B4 Down\r\n"); |
652,11 → 642,18 |
#endif |
break; |
/* -----------------------------------------------------------*/ |
case MSGTYPE_INT1: |
#ifdef _BASE_STATION |
wake(); |
IR_receive_flag = 1; |
sleep(); |
// DBG_PRINT_MAIN("Main: INT1 Interrupt\r\n"); |
#endif |
break; |
/* --- Timer Interrupt Handlers ------------------------------*/ |
case MSGTYPE_TIMER0: |
DBG_PRINT_MAIN("Main: Timer 0 Interrupt\r\n"); |
#ifdef _BASE_STATION |
pwm_LED_off(); |
IR_receive_flag = 0; // Reset IR receive flag |
INTCON3bits.INT1IE = 1; // Turn on INT1 interrupt |
#endif |
665,27 → 662,6 |
case MSGTYPE_TIMER1: |
DBG_PRINT_MAIN("Main: Timer 1 Interrupt\r\n"); |
#ifdef _REMOTE |
// /* XBee Demo */ |
// frame_tx_data = (void *) msgbuffer; |
// frame_tx_data->frame_type = XBEE_TX_DATA_PACKET; |
// frame_tx_data->frame_id = 0; |
// frame_tx_data->destination_64.UPPER_32.long_value = 0x00000000; |
// frame_tx_data->destination_64.LOWER_32.long_value = 0x00000000; |
// ConvertEndian64(&frame_tx_data->destination_64); |
// frame_tx_data->destination_16.INT_16.int_value = xbee_parent_address; |
// ConvertEndian16(&frame_tx_data->destination_16); |
// frame_tx_data->broadcast_radius = 1; |
// frame_tx_data->options = 0x01; // Disable ACK |
// frame_tx_data->data[0] = counter; |
// |
// led_driver_num(counter); |
// counter++; |
// if (counter == 100) |
// counter = 0; |
// |
// length = XBEE_TX_DATA_PACKET_FRAME_SIZE + 1; |
// xbee_process_transmit_frame((void *) msgbuffer, length); |
|
/* Read values from accelerometer and gyroscope */ |
if (i2c_state == I2C_STATE_READ_GYRO) { |
imu_read_acc(); |
702,9 → 678,9 |
case MSGTYPE_TIMER2: |
DBG_PRINT_MAIN("Main: Timer 2 Interrupt\r\n"); |
#ifdef _BASE_STATION |
IR_receive_flag = 0; |
pwm_LED_off(); |
INTCON3bits.INT1IE = 1; // Turn on INT1 interrupt |
// IR_receive_flag = 0; |
// pwm_LED_off(); |
// INTCON3bits.INT1IE = 1; // Turn on INT1 interrupt |
#endif |
break; |
// case MSGTYPE_ADC_NEWVALUE: |