A Atmel RF2xx Radio Library for Mbed

Dependents:   xBedRadio MxSniffer

Committer:
fredqian
Date:
Thu Apr 09 16:42:51 2015 +0800
Revision:
0:5f1d66c85ae0
init commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fredqian 0:5f1d66c85ae0 1 /* Copyright (c) 2011 Frank Zhao
fredqian 0:5f1d66c85ae0 2 All rights reserved.
fredqian 0:5f1d66c85ae0 3
fredqian 0:5f1d66c85ae0 4 Redistribution and use in source and binary forms, with or without
fredqian 0:5f1d66c85ae0 5 modification, are permitted provided that the following conditions
fredqian 0:5f1d66c85ae0 6 are met:
fredqian 0:5f1d66c85ae0 7
fredqian 0:5f1d66c85ae0 8 * Redistributions of source code must retain the above copyright
fredqian 0:5f1d66c85ae0 9 notice, this list of conditions and the following disclaimer.
fredqian 0:5f1d66c85ae0 10 * Redistributions in binary form must reproduce the above copyright
fredqian 0:5f1d66c85ae0 11 notice, this list of conditions and the following disclaimer in the
fredqian 0:5f1d66c85ae0 12 documentation and/or other materials provided with the distribution.
fredqian 0:5f1d66c85ae0 13 * Neither the name of the authors nor the names of its contributors
fredqian 0:5f1d66c85ae0 14 may be used to endorse or promote products derived from this software
fredqian 0:5f1d66c85ae0 15 without specific prior written permission.
fredqian 0:5f1d66c85ae0 16
fredqian 0:5f1d66c85ae0 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
fredqian 0:5f1d66c85ae0 18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
fredqian 0:5f1d66c85ae0 19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
fredqian 0:5f1d66c85ae0 20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
fredqian 0:5f1d66c85ae0 21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
fredqian 0:5f1d66c85ae0 22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
fredqian 0:5f1d66c85ae0 23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
fredqian 0:5f1d66c85ae0 24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
fredqian 0:5f1d66c85ae0 25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
fredqian 0:5f1d66c85ae0 26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
fredqian 0:5f1d66c85ae0 27 POSSIBILITY OF SUCH DAMAGE. */
fredqian 0:5f1d66c85ae0 28
fredqian 0:5f1d66c85ae0 29 #include "MxRadio.h"
fredqian 0:5f1d66c85ae0 30
fredqian 0:5f1d66c85ae0 31
fredqian 0:5f1d66c85ae0 32 void (*user_radio_error)(radio_error_t) = 0;
fredqian 0:5f1d66c85ae0 33 void (*user_radio_irq)(uint8_t) = 0;
fredqian 0:5f1d66c85ae0 34 uint8_t* (*user_radio_receive_frame)(uint8_t, uint8_t*, uint8_t,int8_t, uint8_t) = 0;
fredqian 0:5f1d66c85ae0 35 void (*user_radio_tx_done)(radio_tx_done_t) = 0;
fredqian 0:5f1d66c85ae0 36
fredqian 0:5f1d66c85ae0 37 void cMxRadio::zr_attach_error(void (*funct)(radio_error_t))
fredqian 0:5f1d66c85ae0 38 {
fredqian 0:5f1d66c85ae0 39 user_radio_error = funct;
fredqian 0:5f1d66c85ae0 40 }
fredqian 0:5f1d66c85ae0 41
fredqian 0:5f1d66c85ae0 42 void cMxRadio::zr_attach_irq(void (*funct)(uint8_t))
fredqian 0:5f1d66c85ae0 43 {
fredqian 0:5f1d66c85ae0 44 user_radio_irq = funct;
fredqian 0:5f1d66c85ae0 45 }
fredqian 0:5f1d66c85ae0 46
fredqian 0:5f1d66c85ae0 47 void cMxRadio::zr_attach_receive_frame(uint8_t* (cMxRadio::*funct)(uint8_t, uint8_t*, uint8_t, int8_t, uint8_t))
fredqian 0:5f1d66c85ae0 48 {
fredqian 0:5f1d66c85ae0 49 user_radio_receive_frame = funct;
fredqian 0:5f1d66c85ae0 50 }
fredqian 0:5f1d66c85ae0 51
fredqian 0:5f1d66c85ae0 52 void cMxRadio::zr_attach_tx_done(void (cMxRadio::*funct)(radio_tx_done_t))
fredqian 0:5f1d66c85ae0 53 {
fredqian 0:5f1d66c85ae0 54 user_radio_tx_done = funct;
fredqian 0:5f1d66c85ae0 55 }
fredqian 0:5f1d66c85ae0 56 void cMxRadio::usr_radio_error(radio_error_t err)
fredqian 0:5f1d66c85ae0 57 {
fredqian 0:5f1d66c85ae0 58 if (user_radio_error) user_radio_error(err);
fredqian 0:5f1d66c85ae0 59 }
fredqian 0:5f1d66c85ae0 60
fredqian 0:5f1d66c85ae0 61 void cMxRadio::usr_radio_irq(uint8_t cause)
fredqian 0:5f1d66c85ae0 62 {
fredqian 0:5f1d66c85ae0 63 if (user_radio_irq) user_radio_irq(cause);
fredqian 0:5f1d66c85ae0 64 }
fredqian 0:5f1d66c85ae0 65
fredqian 0:5f1d66c85ae0 66 uint8_t* cMxRadio::usr_radio_receive_frame(uint8_t len, uint8_t *frm, uint8_t lqi, int8_t ed,uint8_t crc_fail)
fredqian 0:5f1d66c85ae0 67 {
fredqian 0:5f1d66c85ae0 68 if (user_radio_receive_frame)
fredqian 0:5f1d66c85ae0 69 return (this->*user_radio_receive_frame)(len, frm, lqi,ed, crc_fail);
fredqian 0:5f1d66c85ae0 70 else return frm;
fredqian 0:5f1d66c85ae0 71 }
fredqian 0:5f1d66c85ae0 72
fredqian 0:5f1d66c85ae0 73 void cMxRadio::usr_radio_tx_done(radio_tx_done_t status)
fredqian 0:5f1d66c85ae0 74 {
fredqian 0:5f1d66c85ae0 75 if (user_radio_tx_done) (this->*user_radio_tx_done)(status);
fredqian 0:5f1d66c85ae0 76 }