39 #define CONFIG_SLAVE_ENABLE() CONFIG_RB3_AS_DIG_OUTPUT()
40 #define SLAVE_ENABLE() _LATB3 = 0 //low true assertion
41 #define SLAVE_DISABLE() _LATB3 = 1
43 #define CONFIG_SLAVE_ORDY() CONFIG_RB2_AS_DIG_INPUT()
44 #define SLAVE_ORDY _RB2
46 void configSPI1(
void) {
48 SPI1CON1 = SEC_PRESCAL_1_1 |
54 #if (defined(__dsPIC33E__) || defined(__PIC24E__))
59 CONFIG_RP6_AS_DIG_PIN();
61 CONFIG_RP7_AS_DIG_PIN();
63 CONFIG_RP5_AS_DIG_PIN();
65 CONFIG_SLAVE_ENABLE();
68 SPI1STATbits.SPIEN = 1;
72 STATE_GET_IN_STRING = 0,
76 void sendStringSPI1(
char* psz_s1) {
86 void getStringSPI1(
char* psz_s1,
uint16_t u16_maxCount) {
88 if (!u16_maxCount)
return;
94 }
while (*(psz_s1-1) && (u16_i <u16_maxCount));
102 char sz_1[BUFSIZE+1];
108 e_mystate = STATE_GET_IN_STRING;
111 case STATE_GET_IN_STRING:
114 sendStringSPI1(sz_1);
115 e_mystate = STATE_GET_REV_STRING;
118 case STATE_GET_REV_STRING:
120 getStringSPI1(sz_1,BUFSIZE+1);
123 e_mystate = STATE_GET_IN_STRING;
127 e_mystate = STATE_GET_IN_STRING;