Elisa3
mirf.h
Go to the documentation of this file.
00001 /*
00002     Copyright (c) 2007 Stefan Engelke <mbox@stefanengelke.de>
00003 
00004     Permission is hereby granted, free of charge, to any person 
00005     obtaining a copy of this software and associated documentation 
00006     files (the "Software"), to deal in the Software without 
00007     restriction, including without limitation the rights to use, copy, 
00008     modify, merge, publish, distribute, sublicense, and/or sell copies 
00009     of the Software, and to permit persons to whom the Software is 
00010     furnished to do so, subject to the following conditions:
00011 
00012     The above copyright notice and this permission notice shall be 
00013     included in all copies or substantial portions of the Software.
00014 
00015     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
00016     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
00017     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
00018     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
00019     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
00020     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
00021     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
00022     DEALINGS IN THE SOFTWARE.
00023 
00024     $Id$
00025 */
00026 
00027 #ifndef _MIRF_H_
00028 #define _MIRF_H_
00029 
00030 #include <avr/io.h>
00031 #include "variables.h"
00032 #include "leds.h"
00033 #include "sensors.h"
00034 #include "utility.h"
00035 
00036 
00037 // Mirf settings
00038 #define mirf_CH         40
00039 #define mirf_PAYLOAD    16
00040 #define mirf_CONFIG     ( (1<<MASK_RX_DR) | (1<<EN_CRC) | (0<<CRCO) )
00041 
00042 // Pin definitions for chip select and chip enabled of the MiRF module
00043 #define CE  PB4
00044 #define CSN PB0
00045 
00046 // Definitions for selecting and enabling MiRF module
00047 #define mirf_CSN_hi     PORTB |=  (1<<CSN);
00048 #define mirf_CSN_lo     PORTB &= ~(1<<CSN);
00049 #define mirf_CE_hi      PORTB |=  (1<<CE);
00050 #define mirf_CE_lo      PORTB &= ~(1<<CE);
00051 
00052 #ifdef __cplusplus
00053 extern "C" {
00054 #endif
00055 
00056 // Public standard functions
00057 void mirf_init();
00058 void mirf_config();
00059 void mirf_send(uint8_t * value, uint8_t len);
00060 void mirf_set_RADDR(uint8_t * adr);
00061 void mirf_set_TADDR(uint8_t * adr);
00062 uint8_t mirf_data_ready();
00063 void mirf_get_data(uint8_t * data);
00064 uint8_t rx_fifo_is_empty();
00065 void flush_rx_fifo();
00066 
00067 void writeAckPayload(unsigned char *data, unsigned char size);
00068 void flushTxFifo();
00069 void handleRFCommands();
00070 uint8_t readPayloadWidthFromTopFifo();
00071 uint8_t readPayloadWidthFromPipe0();
00072 void rfEnableDebugMode();
00073 void rfDisableDebugMode();
00074 void rfDebugSendData();
00075 void rfDebugNextPacket();
00076 
00077 // Public extended functions
00078 void mirf_config_register(uint8_t reg, uint8_t value);
00079 void mirf_read_register(uint8_t reg, uint8_t * value, uint8_t len);
00080 void mirf_write_register(uint8_t reg, uint8_t * value, uint8_t len);
00081 
00082 #ifdef __cplusplus
00083 } // extern "C"
00084 #endif
00085 
00086 #endif /* _MIRF_H_ */
 All Files Functions Variables Defines