1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-26 05:17:19 +02:00
ben-wpan/atusb/fw/board.h
Alexander Aring 5129029d3b atusb: fw: add support for rzusbstick
This patch adds support for the rzusbstick for the atusb firmware.
More detailed information about this usb stick:

http://www.atmel.com/tools/rzusbstick.aspx

Original I have the rzraven kit:

http://www.atmel.com/tools/rzraven.aspx

Which comes with a special cable and avr dragon programmer. You need
some programmer and wires to the programmers pins. To lookup how to
connect the programmer to the rzusbstick pinout, see:

http://www.atmel.com/Images/doc8117.pdf

page 22 (schematics of the rzusbstick).

Difference between atusb and rzusbstick(rzusb) is mainly the at86rf231
vs at86rf230 one. The rzusb contains the at86rf230 which is a little bit
hard to deal with it (and has a huge errata inside the datasheet).
Nevertheless with small schanges the atusb firmware can run now on the
rzusb. The rzusb contains also a bigger mcu, so we can maybe cache more
pdus for receive handling.

To compile the rzusb firmware call:
make NAME=rzusb

this will generate the rzusb.bin

then call the programmer (in my case avrdude):
avrdude -P usb -c dragon_jtag -p usb1287 -U flash:w:rzusb.bin

NOTE: currently there is no chance (I suppose) to ensure that the atusb
receive the correct firmware, so don't try to flash the atusb with the
rzusb firmware! Also the vendor and product id is the same.

This currently a RFC, it's a quick hack and I think we should update
more the documentation to support the rzusb.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Cc: Stefan Schmidt <stefan@osg.samsung.com>
Cc: Werner Almesberger <werner@almesberger.net>
2016-03-18 20:45:40 +01:00

128 lines
2.6 KiB
C

/*
* fw/board.h - Board-specific functions and definitions
*
* Written 2008-2011, 2013, 2013 by Werner Almesberger
* Copyright 2008-2011, 2013, 2013 Werner Almesberger
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef BOARD_H
#define BOARD_H
#include <stdbool.h>
#include <stdint.h>
#include <atusb/atusb.h>
#ifdef ATUSB
#define LED_PORT B
#define LED_BIT 6
#define nRST_RF_PORT C
#define nRST_RF_BIT 7
#define SLP_TR_PORT B
#define SLP_TR_BIT 4
#define SCLK_PORT D
#define SCLK_BIT 5
#define MOSI_PORT D
#define MOSI_BIT 3
#define MISO_PORT D
#define MISO_BIT 2
#define nSS_PORT D
#define nSS_BIT 1
#define IRQ_RF_PORT D
#define IRQ_RF_BIT 0
#define SPI_WAIT_DONE() while (!(UCSR1A & 1 << RXC1))
#define SPI_DATA UDR1
#endif
#ifdef RZUSB
#define LED_PORT D
#define LED_BIT 7
#define nRST_RF_PORT B
#define nRST_RF_BIT 5
#define SLP_TR_PORT B
#define SLP_TR_BIT 4
#define SCLK_PORT B
#define SCLK_BIT 1
#define MOSI_PORT B
#define MOSI_BIT 2
#define MISO_PORT B
#define MISO_BIT 3
#define nSS_PORT B
#define nSS_BIT 0
#define IRQ_RF_PORT D
#define IRQ_RF_BIT 4
#define SPI_WAIT_DONE() while ((SPSR & (1 << SPIF)) == 0)
#define SPI_DATA SPDR
#endif
#define SET_2(p, b) PORT##p |= 1 << (b)
#define CLR_2(p, b) PORT##p &= ~(1 << (b))
#define IN_2(p, b) DDR##p &= ~(1 << (b))
#define OUT_2(p, b) DDR##p |= 1 << (b)
#define PIN_2(p, b) ((PIN##p >> (b)) & 1)
#define SET_1(p, b) SET_2(p, b)
#define CLR_1(p, b) CLR_2(p, b)
#define IN_1(p, b) IN_2(p, b)
#define OUT_1(p, b) OUT_2(p, b)
#define PIN_1(p, b) PIN_2(p, b)
#define SET(n) SET_1(n##_PORT, n##_BIT)
#define CLR(n) CLR_1(n##_PORT, n##_BIT)
#define IN(n) IN_1(n##_PORT, n##_BIT)
#define OUT(n) OUT_1(n##_PORT, n##_BIT)
#define PIN(n) PIN_1(n##_PORT, n##_BIT)
#define USB_VENDOR ATUSB_VENDOR_ID
#define USB_PRODUCT ATUSB_PRODUCT_ID
#define DFU_USB_VENDOR USB_VENDOR
#define DFU_USB_PRODUCT USB_PRODUCT
#define BOARD_MAX_mA 40
#ifdef BOOT_LOADER
#define NUM_EPS 1
#else
#define NUM_EPS 2
#endif
#define HAS_BOARD_SERNUM
extern uint8_t board_sernum[42];
extern uint8_t irq_serial;
void reset_rf(void);
void reset_cpu(void);
uint8_t read_irq(void);
void slp_tr(void);
void led(bool on);
void panic(void);
uint64_t timer_read(void);
void timer_init(void);
bool gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res);
void gpio_cleanup(void);
void board_init(void);
void board_app_init(void);
#endif /* !BOARD_H */