Blame | Last modification | View Log | Download
#include "test.h"#define H1 PIN_A1#define L1 PIN_A2#define H2 PIN_A3#define L2 PIN_A4char command;int n;#INT_SSPvoid ssp_interupt (){BYTE incoming, state;output_low(H1);output_low(L1);output_low(H2);output_low(L2);state = i2c_isr_state();if(state < 0x80) //Master is sending data{output_toggle(PIN_A0);command = i2c_read();}if(state == 0x80) //Master is requesting data{i2c_write(command);}}void main(){setup_adc_ports(NO_ANALOGS|VSS_VDD);setup_adc(ADC_OFF);setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);setup_timer_1(T1_DISABLED);setup_timer_2(T2_DISABLED,0,1);setup_comparator(NC_NC_NC_NC);setup_vref(FALSE);setup_oscillator(False);enable_interrupts(GLOBAL);enable_interrupts(INT_SSP);while(true){if(command=='a'){output_high(H1);output_low(H2);output_low(L1);output_high(L2);}else{output_low(H1);output_high(H2);output_high(L1);output_low(L2);};delay_us(60);output_low(H1);output_low(H2);output_low(L1);output_low(L2);}}