Merge CDC-ECM, RNG, DFU bootloader, watchdog, settings manager, energy scan routines of Robert Quattlebaum

This commit is contained in:
dak664 2010-09-17 21:59:09 +00:00
parent 7b529cac03
commit 110bc0242e
42 changed files with 4739 additions and 2669 deletions

View file

@ -35,36 +35,64 @@
#include "contiki-raven.h"
#if !RF230BB
#include "zmac.h"
#else
extern uint64_t macLongAddr;
#endif
#include "sicslowpan.h"
extern uint64_t rndis_ethernet_addr;
#include "sicslow_ethernet.h"
#include "rndis/rndis_task.h"
void byte_reverse(uint8_t * bytes, uint8_t num)
{
uint8_t tempbyte;
uint8_t i, j;
i = 0;
j = num - 1;
while(i < j) {
tempbyte = bytes[i];
bytes[i] = bytes[j];
bytes[j] = tempbyte;
j--;
i++;
}
return;
}
void
init_net(void)
{
extern uint64_t macLongAddr;
uint64_t usb_ethernet_addr;
// Because all of the logic below is done using little-endian
// 64-bit integers, we need to reverse the byte order before
// we can continue;
byte_reverse((uint8_t*)&macLongAddr,8);
/* Set local bit, Clear translate bit, Clear Multicast bit */
macLongAddr &= ~(0x0700000000000000ULL);
macLongAddr |= 0x0200000000000000ULL;
/* Set local bit, Clear translate bit, Clear Multicast bit */
macLongAddr &= ~(0x0700000000000000ULL);
macLongAddr |= 0x0200000000000000ULL;
/* Set the Ethernet address to the 15.4 MAC address */
rndis_ethernet_addr = macLongAddr;
/* Remove the middle two bytes... */
rndis_ethernet_addr = (rndis_ethernet_addr & 0xffffffUL) | ((rndis_ethernet_addr & 0xffffff0000000000ULL) >> 16);
/* Set the Ethernet address to the 15.4 MAC address */
usb_ethernet_addr = macLongAddr;
/* Change ieee802.15.4 address to correspond with what the ethernet's
IPv6 address will be. This will have ff:fe in the middle. */
macLongAddr = (macLongAddr & 0xffffff0000ffffffULL) | (0x000000fffe000000ULL);
/* Remove the middle two bytes... */
usb_ethernet_addr = (usb_ethernet_addr & 0xffffffUL) | ((usb_ethernet_addr & 0xffffff0000000000ULL) >> 16);
/* Change ieee802.15.4 address to correspond with what the ethernet's
IPv6 address will be. This will have ff:fe in the middle. */
macLongAddr = (macLongAddr & 0xffffff0000ffffffULL) | (0x000000fffe000000ULL);
#if !RF230BB
ieee15_4ManagerAddress.set_long_addr(macLongAddr);
ieee15_4ManagerAddress.set_long_addr(macLongAddr);
#endif
byte_reverse((uint8_t*)&macLongAddr,8);
byte_reverse((uint8_t*)&usb_ethernet_addr,6);
usb_eth_set_mac_address((uint8_t*)&usb_ethernet_addr);
}