alan broad
/
carbon_v5_arm_studio
arm studio build
Diff: src/commI2C.cpp
- Revision:
- 18:d95e1a2c4303
- Parent:
- 17:74d60177c6b6
- Child:
- 26:f51ff4ad7a93
--- a/src/commI2C.cpp Fri Jan 25 01:46:26 2019 +0000 +++ b/src/commI2C.cpp Sun Jan 27 15:27:53 2019 +0000 @@ -9,8 +9,7 @@ extern Serial pc; extern bool verbose; -//#define TEST - +//#define TEST //============================================================================== // i2c_proc_init // - init i2c comm to proc @@ -62,8 +61,8 @@ wake.mode(OpenDrain); wake.output(); wake = 1; - wait_ms(10); //proc uses interrupts on lora_wake, so don't need to wait,just pulse it - wake = 0; // set wake lo + wait_ms(10); //proc uses interrupts on lora_wake, so don't need to wait,just pulse it + wake = 0; //set wake lo wait_ms(1); wake.input(); //go back to input mode !!! wake pull hi if go back to input mode ??? return; @@ -93,20 +92,23 @@ // - 0x000fffff gives a 1.1 second timeout // - after proc wakes xdot from sleep then proc must send an i2c omd within timout // - once xdot pulses wake to notify proc that i2c ack msg is ready, proc must do i2c read within timeout +// Jan2019: modified to handle large mcast code frags +// - Input parameters: +// buf_xmt: pointer to buffer containing I2C data for transfer to psco +// buf_rcv: pointer to buffer continaing I2C data for transfer from psoc //============================================================================== -I2C_XFR_TYPE i2c_proc_comm(void) +I2C_XFR_TYPE i2c_proc_comm(uint8_t *buf_xmt,uint8_t *buf_rcv,uint16_t bufSize) { - uint32_t timeout = 0x000fffff; //1.1second timeout while(1){ int i = slave.receive(); switch (i) { case I2CSlave::ReadAddressed: //xdot -> proc - slave.write((char *)buf_xmt, BUFFER_SIZE_I2C); + slave.write((char *)buf_xmt,bufSize); return I2C_WRITE; case I2CSlave::WriteAddressed: //xdot <- proc - slave.read((char *)buf_rcv, BUFFER_SIZE_I2C); + slave.read((char *)buf_rcv,bufSize); /* if (verbose){ pc.printf("\n\r Incoming buffer(hex): \n\r");