mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 06:08:27 +02:00
atusb/fw: add EUI64 read and write fw interface to permanently set an EUI64
The kernel driver will now ask for ATUSB_EUI64_READ during init and sets this extended address if available. Use the atusb-eui64 utility from the tools folder to read or set the permanent address. After a new address is set the device will reset to make sure we are in a sane state after the change.
This commit is contained in:
parent
55de8c6373
commit
583a7b72ee
@ -3,6 +3,7 @@
|
||||
*
|
||||
* Written 2008-2011, 2013 by Werner Almesberger
|
||||
* Copyright 2008-2011, 2013 Werner Almesberger
|
||||
* Copyright 2015-2016 Stefan Schmidt
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -16,6 +17,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
#define F_CPU 8000000UL
|
||||
#include <util/delay.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
@ -44,6 +49,14 @@ static uint8_t buf[MAX_PSDU+3]; /* command, PHDR, and LQI */
|
||||
static uint8_t size;
|
||||
|
||||
|
||||
static void do_eeprom_write(void *user)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
eeprom_update_byte((uint8_t*)i, buf[i]);
|
||||
}
|
||||
|
||||
static void do_buf_write(void *user)
|
||||
{
|
||||
uint8_t i;
|
||||
@ -246,6 +259,18 @@ static bool my_setup(const struct setup_request *setup)
|
||||
return mac_rx(setup->wValue);
|
||||
case ATUSB_TO_DEV(ATUSB_TX):
|
||||
return mac_tx(setup->wValue, setup->wIndex, setup->wLength);
|
||||
case ATUSB_TO_DEV(ATUSB_EUI64_WRITE):
|
||||
debug("ATUSB_EUI64_WRITE\n");
|
||||
usb_recv(&eps[0], buf, setup->wLength, do_eeprom_write, NULL);
|
||||
_delay_ms(100);
|
||||
reset_cpu();
|
||||
return 1;
|
||||
|
||||
case ATUSB_FROM_DEV(ATUSB_EUI64_READ):
|
||||
debug("ATUSB_EUI64_READ\n");
|
||||
eeprom_read_block(buf, (const void*)0, 8);
|
||||
usb_send(&eps[0], buf, 8, NULL, NULL);
|
||||
return 1;
|
||||
|
||||
default:
|
||||
error("Unrecognized SETUP: 0x%02x 0x%02x ...\n",
|
||||
|
@ -46,6 +46,8 @@ enum atusb_requests {
|
||||
ATUSB_SPI_WRITE2_SYNC,
|
||||
ATUSB_RX_MODE = 0x40, /* HardMAC group */
|
||||
ATUSB_TX,
|
||||
ATUSB_EUI64_WRITE = 0x50, /* Parameter in EEPROM grp */
|
||||
ATUSB_EUI64_READ,
|
||||
};
|
||||
|
||||
/*
|
||||
@ -77,6 +79,8 @@ enum atusb_requests {
|
||||
*
|
||||
* host-> ATUSB_RX_MODE on - 0
|
||||
* host-> ATUSB_TX flags ack_seq #bytes
|
||||
* host-> ATUSB_EUI64_WRITE - - #bytes (8)
|
||||
* ->host ATUSB_EUI64_READ - - #bytes (8)
|
||||
*/
|
||||
|
||||
#define ATUSB_REQ_FROM_DEV (USB_TYPE_VENDOR | USB_DIR_IN)
|
||||
|
Loading…
Reference in New Issue
Block a user