mrf24j40.c File Reference

#include "mrf24j40.h"
#include "pic_utils.h"
#include "spi_hw.h"
#include "pic_serial.h"
Include dependency graph for mrf24j40.c:

Go to the source code of this file.

Functions

void mrf24h40_pan_association_requested ()
void mrf24j40_active_channel_scan ()
void mrf24j40_associate_to_pan ()
void mrf24j40_flush_receive_buffer ()
 Flush receive buffer of mrf24j40.
void mrf24j40_handle_isr ()
 Interrupt service routine for mrf24j40 chip.
void mrf24j40_init ()
 Initialises mrf24j40 chip ready for use.
void mrf24j40_init_coordinator ()
uns8 mrf24j40_long_addr_read (uns16 addr)
 Read data from long address of memory location in mrf24j40.
void mrf24j40_long_addr_write (uns16 addr, uns8 data)
 Write data to long address memory location.
void mrf24j40_orphan_channel_scan ()
void mrf24j40_realign_pan ()
uns8 mrf24j40_receive (uns8 *data, uns8 bytes_to_receive)
 Pull received data from buffer.
uns8 mrf24j40_scan_for_lowest_channel_ed ()
 Scan all channels for lowest RF energy.
void mrf24j40_set_channel (uns8 channel)
 Change channels.
void mrf24j40_set_extended_address (uns8 *_extended_address)
 Set extended address.
void mrf24j40_set_pan_id (uns16 _pan_id)
 Set PAN id.
void mrf24j40_set_short_address (uns16 _short_address)
 Set short address.
void mrf24j40_setup_io ()
 Setup ports/pins as inputs/outputs ready for use.
uns8 mrf24j40_short_addr_read (uns8 addr)
 Read data from short address of memory location in mrf24j40.
void mrf24j40_short_addr_write (uns8 addr, uns8 data)
 Write data to short address memory location.
void mrf24j40_start_pan ()
void mrf24j40_transmit (uns8 *data, uns8 bytes_to_transmit)
 Transmit raw data.
void mrf24j40_transmit_to_extended_address (uns8 frame_type, uns16 dest_pan_id, uns8 *dest_extended_address, uns8 *data, uns8 data_length, uns8 ack)
 Transmit packet to extended address.
void mrf24j40_transmit_to_short_address (uns8 frame_type, uns16 dest_pan_id, uns16 dest_short_address, uns8 *data, uns8 bytes_to_transmit, uns8 ack)
 Transmit packet to short address.

Variables

uns8 current_channel = 0
uns8 data_sequence_number
uns8 extended_address [8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
uns16 pan_id = 0xffff
uns16 short_address = 0xffff

Function Documentation

void mrf24h40_pan_association_requested (  ) 

Definition at line 242 of file mrf24j40.c.

void mrf24j40_active_channel_scan (  ) 
void mrf24j40_associate_to_pan (  ) 

Definition at line 236 of file mrf24j40.c.

void mrf24j40_flush_receive_buffer (  ) 

No need to call this routine normally, except according to mrf24j40 errata (promiscuous mode)

Definition at line 52 of file mrf24j40.c.

References mrf24j40_short_addr_read(), mrf24j40_short_addr_write(), RXFLUSH, RXFLUSH_RXFLUSH, and uns8.

Referenced by mrf24j40_receive_callback().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_handle_isr (  ) 

Call this routine when the mrf24j40 indicates an interrupt condition, or called regularly.

Definition at line 287 of file mrf24j40.c.

References INTSTAT, INTSTAT_RXIF, INTSTAT_TXNIF, mrf24j40_receive_callback(), mrf24j40_short_addr_read(), mrf24j40_transmit_callback(), serial_print_int_hex(), serial_print_nl(), serial_print_str(), TXSTAT, TXSTAT_CCAFAIL, and uns8.

Here is the call graph for this function:

void mrf24j40_init (  ) 

Sets int pin as input and cs pin as output.

Definition at line 499 of file mrf24j40.c.

References BBREG2, BBREG6, BBREG6_RSSIMODE2, CCAEDTH, data_sequence_number, mrf24j40_long_addr_read(), mrf24j40_long_addr_write(), mrf24j40_short_addr_read(), mrf24j40_short_addr_write(), MRF_INTCON, MRF_INTCON_RXIE, MRF_INTCON_TXNIE, PACON2, RFCON0, RFCON1, RFCON2, RFCON3, RFCON6, RFCON7, RFCON8, RFCTL, RFSTATE, SLPCON1, SOFTRST, TESTMODE, TXSTBL, and uns8.

Referenced by wpan_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_init_coordinator (  ) 
uns8 mrf24j40_long_addr_read ( uns16  addr  ) 

Returns the value in the memory location specified.

Parameters:
addr Long address memory location (see mrf24h40_defines.h)

Definition at line 749 of file mrf24j40.c.

References clear_pin, set_pin, spi_hw_receive(), spi_hw_transmit(), and uns8.

Referenced by mrf24j40_active_channel_scan(), mrf24j40_init(), mrf24j40_receive(), and mrf24j40_scan_for_lowest_channel_ed().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_long_addr_write ( uns16  addr,
uns8  data 
)

Sets the memory location to the value specified

Parameters:
addr Long address memory location (see mrf24h40_defines.h)
data Value that the memory location should be set to

Definition at line 767 of file mrf24j40.c.

References clear_pin, set_pin, and spi_hw_transmit().

Referenced by mrf24j40_active_channel_scan(), mrf24j40_init(), mrf24j40_init_coordinator(), mrf24j40_scan_for_lowest_channel_ed(), mrf24j40_set_channel(), mrf24j40_transmit(), mrf24j40_transmit_to_extended_address(), and mrf24j40_transmit_to_short_address().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_orphan_channel_scan (  ) 

Definition at line 226 of file mrf24j40.c.

void mrf24j40_realign_pan (  ) 

Definition at line 233 of file mrf24j40.c.

uns8 mrf24j40_receive ( uns8 *  data,
uns8  bytes_to_receive 
)

Once an interrupt has occured and we know it is because a packet has been received, this routine will pull the data from the mrf receive buffer. This needs to be done quickly so that the next packet is not lost.

Definition at line 312 of file mrf24j40.c.

References BBREG1, BBREG1_RXDECINV, mrf24j40_long_addr_read(), mrf24j40_short_addr_write(), serial_putc(), uns16, and uns8.

Referenced by mrf24j40_receive_callback().

Here is the call graph for this function:

Here is the caller graph for this function:

uns8 mrf24j40_scan_for_lowest_channel_ed (  ) 

Scans through all channels and reports the channel with the lowest Energy Detection level.

Definition at line 77 of file mrf24j40.c.

References BBREG6, BBREG6_RSSIMODE1, BBREG6_RSSIMODE2, BBREG6_RSSIRDY, channel, GPIO, mrf24j40_long_addr_read(), mrf24j40_long_addr_write(), mrf24j40_set_channel(), mrf24j40_short_addr_read(), mrf24j40_short_addr_write(), MRF_FIRST_CHANNEL, MRF_LAST_CHANNEL, RSSI, TESTMODE, TRISGPIO, uns16, and uns8.

Referenced by its1_controller_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_set_channel ( uns8  channel  ) 

Change to the specified channel, in the range MRF_FIRST_CHANNEL to MRF_LAST_CHANNEL.

Parameters:
channel Channel to change to.

Definition at line 63 of file mrf24j40.c.

References current_channel, mrf24j40_long_addr_write(), mrf24j40_short_addr_write(), RFCON0, and RFCTL.

Referenced by its1_controller_init(), its1_device_process(), its2_device_process(), its2_router_init(), mrf24j40_active_channel_scan(), and mrf24j40_scan_for_lowest_channel_ed().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_set_extended_address ( uns8 *  _extended_address  ) 

Set IEEE 802.15.4 extended address.

Sets the 64 bit extended address of the module. Pass a pointer to an 8 byte uns8 array containing the address.

Definition at line 259 of file mrf24j40.c.

References EADR7, extended_address, mrf24j40_short_addr_write(), serial_print_int_hex(), serial_print_nl(), serial_print_str(), serial_putc(), and uns8.

Referenced by its1_controller_init(), and its1_device_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_set_pan_id ( uns16  _pan_id  ) 

Sets the 16 bit PAN id of the module.

Definition at line 252 of file mrf24j40.c.

References mrf24j40_short_addr_write(), pan_id, PANIDH, and PANIDL.

Referenced by its1_controller_init(), its1_device_init(), its2_device_init(), its2_router_init(), and mrf24j40_active_channel_scan().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_set_short_address ( uns16  _short_address  ) 

Sets the 16 bit short address of the module.

Definition at line 273 of file mrf24j40.c.

References mrf24j40_short_addr_write(), SADRH, SADRL, and short_address.

Referenced by its1_controller_init(), its1_device_init(), its2_device_init(), and its2_router_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_setup_io (  ) 

Sets int pin as input and cs pin as output.

Definition at line 785 of file mrf24j40.c.

References make_input, make_output, and set_pin.

Referenced by wpan_setup_io().

Here is the caller graph for this function:

uns8 mrf24j40_short_addr_read ( uns8  addr  ) 

Returns the value in the memory location specified.

Parameters:
addr Short address memory location (see mrf24h40_defines.h)

Definition at line 725 of file mrf24j40.c.

References clear_pin, set_pin, spi_hw_receive(), spi_hw_transmit(), and uns8.

Referenced by mrf24j40_active_channel_scan(), mrf24j40_flush_receive_buffer(), mrf24j40_handle_isr(), mrf24j40_init(), mrf24j40_init_coordinator(), mrf24j40_scan_for_lowest_channel_ed(), mrf24j40_transmit(), mrf24j40_transmit_to_extended_address(), and mrf24j40_transmit_to_short_address().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_short_addr_write ( uns8  addr,
uns8  data 
)

Sets the memory location to the value specified

Parameters:
addr Short address memory location (see mrf24h40_defines.h)
data Value that the memory location should be set to

Definition at line 737 of file mrf24j40.c.

References clear_pin, set_pin, and spi_hw_transmit().

Referenced by mrf24j40_active_channel_scan(), mrf24j40_flush_receive_buffer(), mrf24j40_init(), mrf24j40_init_coordinator(), mrf24j40_receive(), mrf24j40_scan_for_lowest_channel_ed(), mrf24j40_set_channel(), mrf24j40_set_extended_address(), mrf24j40_set_pan_id(), mrf24j40_set_short_address(), mrf24j40_transmit(), mrf24j40_transmit_to_extended_address(), and mrf24j40_transmit_to_short_address().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_start_pan (  ) 

Definition at line 229 of file mrf24j40.c.

void mrf24j40_transmit ( uns8 *  data,
uns8  bytes_to_transmit 
)

Transmit a raw packet - this assumes you have already created an 802.15.4 compatible packet. Normally you would use transmit_to_extended_adddress or transmit_to_short_address instead.

Definition at line 470 of file mrf24j40.c.

References data_sequence_number, mrf24j40_long_addr_write(), mrf24j40_short_addr_read(), mrf24j40_short_addr_write(), TXNCON, TXNCON_TXNTRIG, and uns8.

Here is the call graph for this function:

void mrf24j40_transmit_to_extended_address ( uns8  frame_type,
uns16  dest_pan_id,
uns8 *  dest_extended_address,
uns8 *  data,
uns8  data_length,
uns8  ack 
)

Requests that the mrf24j40 transmit the packet to the specified extended address

Parameters:
frame_type 802.15.4 frame type
dest_pan_id PAN id of destination
dest_extended_address Pointer to uns8 array indicating extended address of destination
data Pointer to uns8 array of bytes to transmit
bytes_to_transmit 
ack Either MRF_ACK or MRF_NO_ACK depending if you want hardware acknowledgement

Definition at line 350 of file mrf24j40.c.

References data_sequence_number, extended_address, mrf24j40_long_addr_write(), mrf24j40_short_addr_read(), mrf24j40_short_addr_write(), pan_id, TXNCON, TXNCON_TXNACKREQ, TXNCON_TXNTRIG, and uns8.

Referenced by its_transmit_to_ea().

Here is the call graph for this function:

Here is the caller graph for this function:

void mrf24j40_transmit_to_short_address ( uns8  frame_type,
uns16  dest_pan_id,
uns16  dest_short_address,
uns8 *  data,
uns8  bytes_to_transmit,
uns8  ack 
)

Requests that the mrf24j40 transmit the packet to the specified short address

Parameters:
frame_type 802.15.4 frame type
dest_pan_id PAN id of destination
dest_short_address 16 bit short address of destination
data Pointer to uns8 array of bytes to transmit
bytes_to_transmit 
ack Either MRF_ACK or MRF_NO_ACK depending if you want hardware acknowledgement

Definition at line 416 of file mrf24j40.c.

References data_sequence_number, mrf24j40_long_addr_write(), mrf24j40_short_addr_read(), mrf24j40_short_addr_write(), pan_id, short_address, TXNCON, TXNCON_TXNACKREQ, TXNCON_TXNTRIG, and uns8.

Referenced by its2_transmit(), and its_transmit_to_sa().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

uns8 current_channel = 0

Definition at line 49 of file mrf24j40.c.

Referenced by mrf24j40_set_channel().

uns8 extended_address[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
uns16 pan_id = 0xffff
uns16 short_address = 0xffff

Definition at line 48 of file mrf24j40.c.

Referenced by mrf24j40_set_short_address(), and mrf24j40_transmit_to_short_address().


Generated on Wed Dec 8 13:47:28 2010 for Pic Pack by  doxygen 1.6.1