CCS/bsl/main.c
/**
 * This function is hidden within the process time of the wisp BEFORE responding to the reader!
 * While the maximum delayed response time is 20 ms, the WISP lives for ~14 ms per power cycle.
 * Furthermore, the bigger this function is, the smaller the time window becomes (i.e. less bwr/sec).
 */
This function is hidden within the process time of the wisp BEFORE responding to the reader.
While the maximum delayed response time is 20 ms, the WISP lives for ~14 ms per power cycle.
Furthermore, the bigger this function is, the smaller the time window becomes .
This function is hidden within the process time of the wisp BEFORE responding to the reader . While the maximum delayed response time is 20 ms the WISP lives for ~14 ms per power cycle . Furthermore the bigger this function is the smaller the time window becomes .
void my_blockWriteCallback  (void) {
	uint8_t word_count = (wispData.blockWriteBufPtr[0] >> 8)  & 0xFF;
	uint8_t size       = ((wispData.blockWriteBufPtr[0])  & 0xFF);
	uint16_t address   = (wispData.blockWriteBufPtr[1]);
	uint8_t checksum   = (wispData.blockWriteBufPtr[word_count] >> 8) & 0xFF;
	uint8_t offset     = 0x00;
	uint8_t calcsum    = 0x00;
	for (offset = word_count; offset > 0; offset--) {
		calcsum += (wispData.blockWriteBufPtr[offset-1] >> 8) & 0xff;
		calcsum += wispData.blockWriteBufPtr[offset-1] & 0xff;
	}
	if (calcsum == checksum) {
		checksum = word_count + size + ((address >> 8) & 0xFF) + (address & 0xFF);
		for (offset = 0x00; offset < size; offset += 0x02) {
			(* (uint16_t *) (address + offset)) =
					((wispData.blockWriteBufPtr[2 + (offset >> 1)] & 0xff) << 8)
					| ((wispData.blockWriteBufPtr[2 + (offset >> 1)] & 0xff00) >> 8);
			checksum += (* (uint8_t *) (address + offset));
			checksum += (* (uint8_t *) (address + offset + 0x01));
		}
		wispData.epcBuf[2]  = word_count;
		wispData.epcBuf[3]  = size;
		wispData.epcBuf[4]  = (address >> 8)  & 0xFF;
		wispData.epcBuf[5]  = (address)  & 0xFF;
		wispData.epcBuf[6]  = checksum;
	}
}
void my_blockWriteCallback ( void ) { uint8_t word_count = ( wispData . blockWriteBufPtr [ 0 ] >> 8 ) & 0xFF ; uint8_t size = ( ( wispData . blockWriteBufPtr [ 0 ] ) & 0xFF ) ; uint16_t address = ( wispData . blockWriteBufPtr [ 1 ] ) ; uint8_t checksum = ( wispData . blockWriteBufPtr [ word_count ] >> 8 ) & 0xFF ; uint8_t offset = 0x00 ; uint8_t calcsum = 0x00 ; for ( offset = word_count ; offset > 0 ; offset -- ) { calcsum += ( wispData . blockWriteBufPtr [ offset - 1 ] >> 8 ) & 0xff ; calcsum += wispData . blockWriteBufPtr [ offset - 1 ] & 0xff ; } if ( calcsum == checksum ) { checksum = word_count + size + ( ( address >> 8 ) & 0xFF ) + ( address & 0xFF ) ; for ( offset = 0x00 ; offset < size ; offset += 0x02 ) { ( * ( uint16_t * ) ( address + offset ) ) = ( ( wispData . blockWriteBufPtr [ 2 + ( offset >> 1 ) ] & 0xff ) << 8 ) | ( ( wispData . blockWriteBufPtr [ 2 + ( offset >> 1 ) ] & 0xff00 ) >> 8 ) ; checksum += ( * ( uint8_t * ) ( address + offset ) ) ; checksum += ( * ( uint8_t * ) ( address + offset + 0x01 ) ) ; } wispData . epcBuf [ 2 ] = word_count ; wispData . epcBuf [ 3 ] = size ; wispData . epcBuf [ 4 ] = ( address >> 8 ) & 0xFF ; wispData . epcBuf [ 5 ] = ( address ) & 0xFF ; wispData . epcBuf [ 6 ] = checksum ; } }
This function is hidden within the process time of the wisp BEFORE responding to the reader!
This function is hidden within the process time of the wisp BEFORE responding to the reader!
// Calculate checksum. // Only do stuff if checksum matches. // Send ACK.