/***************** RadioBackoff ***********************/
async event void SubBackoff.requestInitialBackoff(message_t *msg) {
- signal RadioBackoff.requestInitialBackoff[((cc2420_header_t*)(msg->data -
- sizeof(cc2420_header_t)))->type](msg);
+ signal RadioBackoff.requestInitialBackoff[(TCAST(cc2420_header_t* ONE,
+ (uint8_t*)msg + offsetof(message_t, data) - sizeof(cc2420_header_t)))->type](msg);
}
async event void SubBackoff.requestCongestionBackoff(message_t *msg) {
- signal RadioBackoff.requestCongestionBackoff[((cc2420_header_t*)(msg->data -
- sizeof(cc2420_header_t)))->type](msg);
+ signal RadioBackoff.requestCongestionBackoff[(TCAST(cc2420_header_t* ONE,
+ (uint8_t*)msg + offsetof(message_t, data) - sizeof(cc2420_header_t)))->type](msg);
}
async event void SubBackoff.requestCca(message_t *msg) {
// Lower layers than this do not configure the CCA settings
- signal RadioBackoff.requestCca[((cc2420_header_t*)(msg->data -
- sizeof(cc2420_header_t)))->type](msg);
+ signal RadioBackoff.requestCca[(TCAST(cc2420_header_t* ONE,
+ (uint8_t*)msg + offsetof(message_t, data) - sizeof(cc2420_header_t)))->type](msg);
}
async command void RadioBackoff.setInitialBackoff[am_id_t amId](uint16_t backoffTime) {
S_TRANSMITTING,
};
- message_t* m_msg;
+ message_t* ONE_NOK m_msg;
error_t sendErr = SUCCESS;
command void* Send.getPayload(message_t* m, uint8_t len) {
if (len <= call Send.maxPayloadLength()) {
- return m->data;
+ return (void* COUNT_NOK(len))m->data;
}
else {
return NULL;
* @return status byte returned when sending the last address byte
* of the SPI transaction.
*/
- async command cc2420_status_t beginRead( uint8_t* data, uint8_t length );
+ async command cc2420_status_t beginRead( uint8_t* COUNT_NOK(length) data, uint8_t length );
/**
* Continue reading from the FIFO without having to send the address
* @param length number of bytes to read.
* @return SUCCESS always.
*/
- async command error_t continueRead( uint8_t* data, uint8_t length );
+ async command error_t continueRead( uint8_t* COUNT_NOK(length) data, uint8_t length );
/**
* Signals the completion of a read operation.
* @param length number of bytes read.
* @param error notification of how the operation went
*/
- async event void readDone( uint8_t* data, uint8_t length, error_t error );
+ async event void readDone( uint8_t* COUNT_NOK(length) data, uint8_t length, error_t error );
/**
* Start writing the FIFO. The <code>writeDone</code> event will be
* @return status byte returned when sending the last address byte
* of the SPI transaction.
*/
- async command cc2420_status_t write( uint8_t* data, uint8_t length );
+ async command cc2420_status_t write( uint8_t* COUNT_NOK(length) data, uint8_t length );
/**
* Signals the completion of a write operation.
* @param length number of bytes written.
* @param error notification of how the operation went
*/
- async event void writeDone( uint8_t* data, uint8_t length, error_t error );
+ async event void writeDone( uint8_t* COUNT_NOK(length) data, uint8_t length, error_t error );
}
/**
* @return pointer to the cc2420_header_t of the given message
*/
- async command cc2420_header_t *getHeader(message_t *msg);
+ async command cc2420_header_t * ONE getHeader(message_t * ONE msg);
/**
* @return pointer to the cc2420_metadata_t of the given message
*/
- async command cc2420_metadata_t *getMetadata(message_t *msg);
+ async command cc2420_metadata_t * ONE getMetadata(message_t * ONE msg);
}
* @return status byte returned when sending the last byte
* of the SPI transaction.
*/
- async command cc2420_status_t read( uint8_t offset, uint8_t* data, uint8_t length );
+ async command cc2420_status_t read( uint8_t offset, uint8_t* COUNT_NOK(length) data, uint8_t length );
/**
* Write data to RAM. This operation is sychronous.
* @return status byte returned when sending the last address byte
* of the SPI transaction.
*/
- async command cc2420_status_t write( uint8_t offset, uint8_t* data, uint8_t length );
+ async command cc2420_status_t write( uint8_t offset, uint8_t* COUNT_NOK(length) data, uint8_t length );
}
* @param type of the message received.
* @param message pointer to message received.
*/
- async event void receive( uint8_t type, message_t* message );
+ async event void receive( uint8_t type, message_t* ONE_NOK message );
}
* @param useCca TRUE if this Tx should use clear channel assessments
* @return SUCCESS if the request was accepted, FAIL otherwise.
*/
- async command error_t send( message_t* p_msg, bool useCca );
+ async command error_t send( message_t* ONE p_msg, bool useCca );
/**
* Send the previous message again
* @param p_msg message to send.
* @param error notifaction of how the operation went.
*/
- async event void sendDone( message_t* p_msg, error_t error );
+ async event void sendDone( message_t* ONE_NOK p_msg, error_t error );
/**
* Modify the contents of a packet. This command can only be used
* @param len of bytes to write
* @return SUCCESS if the request was accepted, FAIL otherwise.
*/
- async command error_t modify( uint8_t offset, uint8_t* buf, uint8_t len );
+ async command error_t modify( uint8_t offset, uint8_t* COUNT_NOK(len) buf, uint8_t len );
}
* Reply using setInitialBackoff(..)
* @param msg pointer to the message being sent
*/
- async event void requestInitialBackoff(message_t *msg);
+ async event void requestInitialBackoff(message_t * ONE msg);
/**
* Request for input on the congestion backoff
* Reply using setCongestionBackoff(..)
* @param msg pointer to the message being sent
*/
- async event void requestCongestionBackoff(message_t *msg);
+ async event void requestCongestionBackoff(message_t * ONE msg);
/**
* Request for input on whether or not to use CCA on the outbound packet.
* Replies should come in the form of setCca(..)
* @param msg pointer to the message being sent
*/
- async event void requestCca(message_t *msg);
+ async event void requestCca(message_t * ONE msg);
}
}
/***************** CC2420PacketBody Commands ****************/
- async command cc2420_header_t *CC2420PacketBody.getHeader( message_t* msg ) {
- return (cc2420_header_t*)( msg->data - sizeof( cc2420_header_t ) );
+ async command cc2420_header_t * ONE CC2420PacketBody.getHeader( message_t* ONE msg ) {
+ return TCAST(cc2420_header_t* ONE, (uint8_t *)msg + offsetof(message_t, data) - sizeof( cc2420_header_t ));
}
async command cc2420_metadata_t *CC2420PacketBody.getMetadata( message_t* msg ) {
norace uint8_t m_bytes_left;
- norace message_t* m_p_rx_buf;
+ norace message_t* ONE_NOK m_p_rx_buf;
message_t m_rx_buf;
error_t error ) {
cc2420_header_t* header = call CC2420PacketBody.getHeader( m_p_rx_buf );
cc2420_metadata_t* metadata = call CC2420PacketBody.getMetadata( m_p_rx_buf );
- uint8_t* buf = (uint8_t*) header;
+ uint8_t tmpLen = sizeof(message_t) - (offsetof(message_t, data) - sizeof(cc2420_header_t));
+ uint8_t* COUNT(tmpLen) buf = TCAST(uint8_t* COUNT(tmpLen), header);
rxFrameLength = buf[ 0 ];
switch( m_state ) {
*/
task void receiveDone_task() {
cc2420_metadata_t* metadata = call CC2420PacketBody.getMetadata( m_p_rx_buf );
- uint8_t* buf = (uint8_t*) call CC2420PacketBody.getHeader( m_p_rx_buf );;
+ cc2420_header_t* header = call CC2420PacketBody.getHeader( m_p_rx_buf);
+ uint8_t tmpLen = sizeof(message_t) - (offsetof(message_t, data) - sizeof(cc2420_header_t));
+ uint8_t* COUNT(tmpLen) buf = TCAST(uint8_t* COUNT(tmpLen), header);
metadata->crc = buf[ rxFrameLength ] >> 7;
metadata->lqi = buf[ rxFrameLength ] & 0x7f;
uint8_t len ) {
cc2420_status_t status = 0;
+ uint8_t tmpLen = len;
+ uint8_t * COUNT(tmpLen) tmpData = (uint8_t * COUNT(tmpLen))data;
atomic {
if(call WorkingState.isIdle()) {
status = call SpiByte.write( addr | 0x80 );
call SpiByte.write( ( addr >> 1 ) & 0xc0 );
for ( ; len; len-- ) {
- call SpiByte.write( *data++ );
+ call SpiByte.write( tmpData[tmpLen-len] );
}
return status;
-/*
- * Copyright (c) 2005-2006 Arch Rock Corporation
+/*
+ * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
CC2420_ABORT_PERIOD = 320
};
- norace message_t *m_msg;
+ norace message_t * ONE_NOK m_msg;
norace bool m_cca;
/***************** Prototypes ****************/
- error_t send( message_t *p_msg, bool cca );
+ error_t send( message_t * ONE p_msg, bool cca );
error_t resend( bool cca );
void loadTXFIFO();
void attemptSend();
/**************** Send Commands ****************/
- async command error_t Send.send( message_t* p_msg, bool useCca ) {
+ async command error_t Send.send( message_t* ONE p_msg, bool useCca ) {
return send( p_msg, useCca );
}
* @param *p_msg Pointer to the message that needs to be sent
* @param cca TRUE if this transmit should use clear channel assessment
*/
- error_t send( message_t* p_msg, bool cca ) {
+ error_t send( message_t* ONE p_msg, bool cca ) {
atomic {
if (m_state == S_CANCEL) {
return ECANCEL;
m_tx_power = tx_power;
- call TXFIFO.write( (uint8_t*)header, header->length - 1);
+ {
+ uint8_t tmpLen = header->length - 1;
+ call TXFIFO.write(TCAST(uint8_t * COUNT(tmpLen), header), header->length - 1);
+ }
}
void signalDone( error_t err ) {