2011-02-14 17:48:42 +02:00
|
|
|
/*
|
|
|
|
* fw/board.h - Board-specific functions and definitions
|
|
|
|
*
|
2011-03-09 00:01:54 +02:00
|
|
|
* Written 2008-2011 by Werner Almesberger
|
|
|
|
* Copyright 2008-2011 Werner Almesberger
|
2011-02-14 17:48:42 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2011-02-14 04:46:36 +02:00
|
|
|
#ifndef BOARD_H
|
|
|
|
#define BOARD_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
|
|
#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 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)
|
|
|
|
|
2011-02-14 17:48:42 +02:00
|
|
|
|
2011-03-09 00:01:54 +02:00
|
|
|
#define USB_VENDOR 0x20b7 /* Qi Hardware */
|
|
|
|
#define USB_PRODUCT 0x1540 /* ben-wpan atusb */
|
|
|
|
|
2011-03-09 05:41:32 +02:00
|
|
|
#define DFU_USB_VENDOR USB_VENDOR
|
|
|
|
#define DFU_USB_PRODUCT USB_PRODUCT
|
|
|
|
|
2011-03-09 00:01:54 +02:00
|
|
|
|
2011-06-11 00:48:16 +03:00
|
|
|
#define BOARD_MAX_mA 40
|
|
|
|
|
2011-05-10 23:23:08 +03:00
|
|
|
#define HAS_BOARD_SERNUM
|
|
|
|
|
|
|
|
extern uint8_t board_sernum[42];
|
|
|
|
|
|
|
|
|
2011-02-14 04:46:36 +02:00
|
|
|
void reset_rf(void);
|
2011-05-10 05:52:00 +03:00
|
|
|
void reset_cpu(void);
|
2011-02-14 04:46:36 +02:00
|
|
|
uint8_t read_irq(void);
|
2011-06-06 04:34:49 +03:00
|
|
|
void slp_tr(void);
|
2011-03-09 05:41:32 +02:00
|
|
|
|
2011-02-14 04:46:36 +02:00
|
|
|
void led(int on);
|
|
|
|
void panic(void);
|
2011-03-09 05:41:32 +02:00
|
|
|
|
2011-05-30 03:05:28 +03:00
|
|
|
uint64_t timer_read(void);
|
2011-06-11 07:52:16 +03:00
|
|
|
void timer_init(void);
|
2011-05-30 03:05:28 +03:00
|
|
|
|
2011-06-04 15:40:34 +03:00
|
|
|
int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res);
|
2011-06-21 05:11:09 +03:00
|
|
|
void gpio_cleanup(void);
|
2011-06-04 15:40:34 +03:00
|
|
|
|
2011-02-14 04:46:36 +02:00
|
|
|
void board_init(void);
|
2011-06-20 21:49:33 +03:00
|
|
|
void board_app_init(void);
|
2011-02-14 04:46:36 +02:00
|
|
|
|
|
|
|
#endif /* !BOARD_H */
|