1. contiki-master\cpu\cc26xx-cc13xx\rf-core\ieee-mode.c文件为其相关的函数,改文件只有.C文件,没有.h文件
2. 跳过文件前面的内容,直接跳转到函数的最后有如下代码:
/*---------------------------------------------------------------------------*/
const struct radio_driver ieee_mode_driver = {
init,
prepare,
transmit,
send,
read_frame,
channel_clear,
receiving_packet,
pending_packet,
on,
off,
get_value,
set_value,
get_object,
set_object,
};
/*---------------------------------------------------------------------------*/
这里初始化了一个数据结构,大括号里面的是对结构体的赋值,均属于函数调用。
结构体的定义在contiki-master\core\dev\radio.h中被定义,具体内容为:
/**
* The structure of a device driver for a radio in Contiki.
*/
struct radio_driver {
int (* init)(void);
/** Prepare the radio with a packet to be sent. */
int (* prepare)(const void *payload, unsigned short payload_len);
/** Send the packet that has previously been prepared. */
int (* transmit)(unsigned short transmit_len);
/** Prepare & transmit a packet. */
int (* send)(const void *payload, unsigned short payload_len);
/** Read a received packet into a buffer. */
int (* read)(void *buf, unsigned short buf_len);
/** Perform a Clear-Channel Assessment (CCA) to find out if there is
a packet in the air or not. */
int (* channel_clear)(void);
/** Check if the radio driver is currently receiving a packet */
int (* receiving_packet)(void);
/** Check if the radio driver has just received a packet */
int (* pending_packet)(void);
/** Turn the radio on. */
int (* on)(void);
/** Turn the radio off. */
int (* off)(void);
/** Get a radio parameter value. */
radio_result_t (* get_value)(radio_param_t param, radio_value_t *value);
/** Set a radio parameter value. */
radio_result_t (* set_value)(radio_param_t param, radio_value_t value);
/**
* Get a radio parameter object. The argument 'dest' must point to a
* memory area of at least 'size' bytes, and this memory area will
* contain the parameter object if the function succeeds.
*/
radio_result_t (* get_object)(radio_param_t param, void *dest, size_t size);
/**
* Set a radio parameter object. The memory area referred to by the
* argument 'src' will not be accessed after the function returns.
*/
radio_result_t (* set_object)(radio_param_t param, const void *src,
size_t size);
};
3. 然后在contiki-master\platform\srf06-cc26xx\contiki-conf.h文件中有如下定义;
#define NETSTACK_CONF_RADIO ieee_mode_driver
4. 然后在contiki-master\core\net\netstack.h文件中有如下定义:
#ifndef NETSTACK_RADIO
#ifdef NETSTACK_CONF_RADIO
#define NETSTACK_RADIO NETSTACK_CONF_RADIO
#else /* NETSTACK_CONF_RADIO */
#define NETSTACK_RADIO nullradio_driver
#endif /* NETSTACK_CONF_RADIO */
#endif /* NETSTACK_RADIO */
5. 然后在contiki-master\platform\srf06-cc26xx\contiki-conf.c文件文件中的
static void set_rf_params(void)函数中有对上面内容进行调用完成初始化配置,
NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, RF_CORE_CHANNEL);
NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
NETSTACK_RADIO.get_value(RADIO_PARAM_CHANNEL, &val);
6. contiki-conf.c文件中有main函数,从main函数中可以看到网络相关的初始化函数为:
printf(" Net: ");
printf("%s\n", NETSTACK_NETWORK.name);
printf(" MAC: ");
printf("%s\n", NETSTACK_MAC.name);
printf(" RDC: ");
printf("%s", NETSTACK_RDC.name);
if(NETSTACK_RDC.channel_check_interval() != 0) {
printf(", Channel Check Interval: %u ticks",
NETSTACK_RDC.channel_check_interval());
}
netstack_init();
set_rf_params();
7. 在contiki-master\core\net\netstack.h文件中有如下定义和声明;
struct network_driver {
char *name;
/** Initialize the network driver */
void (* init)(void);
/** Callback for getting notified of incoming packet. */
void (* input)(void);
};
llsec_driver等在其他文件中被定义.
extern const struct network_driver NETSTACK_NETWORK;
extern const struct llsec_driver NETSTACK_LLSEC;
extern const struct rdc_driver NETSTACK_RDC;
extern const struct mac_driver NETSTACK_MAC;
extern const struct radio_driver NETSTACK_RADIO;
extern const struct framer NETSTACK_FRAMER;
同样在该文件中还有:
#ifndef NETSTACK_NETWORK
#ifdef NETSTACK_CONF_NETWORK
#define NETSTACK_NETWORK NETSTACK_CONF_NETWORK
#else /* NETSTACK_CONF_NETWORK */
#define NETSTACK_NETWORK rime_driver
#endif /* NETSTACK_CONF_NETWORK */
#endif /* NETSTACK_NETWORK */
定义
8. 而在contiki-master\platform\srf06-cc26xx\contiki-conf.h文件中有如下定义
#ifndef NETSTACK_CONF_NETWORK
#if NETSTACK_CONF_WITH_IPV6
#define NETSTACK_CONF_NETWORK sicslowpan_driver
#else
#define NETSTACK_CONF_NETWORK rime_driver
#endif /* NETSTACK_CONF_WITH_IPV6 */
#endif /* NETSTACK_CONF_NETWORK */
#ifndef NETSTACK_CONF_MAC
#define NETSTACK_CONF_MAC csma_driver
#endif
#ifndef NETSTACK_CONF_RDC
#define NETSTACK_CONF_RDC contikimac_driver
#endif
如果NETSTACK_CONF_WITH_IPV6被定义,则6中NETSTACK_NETWORK.name为sicslowpan;
文章评论(0条评论)
登录后参与讨论