IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Git Source Tree
Root/
| Source at commit 07b5bfddc052ab98a23cc55c060d07e037f35aae created 6 years 9 months ago. By Werner Almesberger, atusb/atrf.sch: move invisible footprint test, to avoid confusing eeshow | |
|---|---|
| 1 | /* |
| 2 | * fw/board.h - Board-specific functions and definitions |
| 3 | * |
| 4 | * Written 2008-2011, 2013, 2013 by Werner Almesberger |
| 5 | * Copyright 2008-2011, 2013, 2013 Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | #ifndef BOARD_H |
| 14 | #define BOARD_H |
| 15 | |
| 16 | #include <stdbool.h> |
| 17 | #include <stdint.h> |
| 18 | |
| 19 | #include <atusb/atusb.h> |
| 20 | |
| 21 | #ifdef ATUSB |
| 22 | #include "board_atusb.h" |
| 23 | #endif |
| 24 | #ifdef RZUSB |
| 25 | #include "board_rzusb.h" |
| 26 | #endif |
| 27 | |
| 28 | #define SET_2(p, b) PORT##p |= 1 << (b) |
| 29 | #define CLR_2(p, b) PORT##p &= ~(1 << (b)) |
| 30 | #define IN_2(p, b) DDR##p &= ~(1 << (b)) |
| 31 | #define OUT_2(p, b) DDR##p |= 1 << (b) |
| 32 | #define PIN_2(p, b) ((PIN##p >> (b)) & 1) |
| 33 | |
| 34 | #define SET_1(p, b) SET_2(p, b) |
| 35 | #define CLR_1(p, b) CLR_2(p, b) |
| 36 | #define IN_1(p, b) IN_2(p, b) |
| 37 | #define OUT_1(p, b) OUT_2(p, b) |
| 38 | #define PIN_1(p, b) PIN_2(p, b) |
| 39 | |
| 40 | #define SET(n) SET_1(n##_PORT, n##_BIT) |
| 41 | #define CLR(n) CLR_1(n##_PORT, n##_BIT) |
| 42 | #define IN(n) IN_1(n##_PORT, n##_BIT) |
| 43 | #define OUT(n) OUT_1(n##_PORT, n##_BIT) |
| 44 | #define PIN(n) PIN_1(n##_PORT, n##_BIT) |
| 45 | |
| 46 | |
| 47 | #define USB_VENDOR ATUSB_VENDOR_ID |
| 48 | #define USB_PRODUCT ATUSB_PRODUCT_ID |
| 49 | |
| 50 | #define DFU_USB_VENDOR USB_VENDOR |
| 51 | #define DFU_USB_PRODUCT USB_PRODUCT |
| 52 | |
| 53 | |
| 54 | #define BOARD_MAX_mA 40 |
| 55 | |
| 56 | #ifdef BOOT_LOADER |
| 57 | #define NUM_EPS 1 |
| 58 | #else |
| 59 | #define NUM_EPS 2 |
| 60 | #endif |
| 61 | |
| 62 | #define HAS_BOARD_SERNUM |
| 63 | |
| 64 | extern uint8_t board_sernum[42]; |
| 65 | extern uint8_t irq_serial; |
| 66 | |
| 67 | |
| 68 | void reset_rf(void); |
| 69 | void reset_cpu(void); |
| 70 | uint8_t read_irq(void); |
| 71 | void slp_tr(void); |
| 72 | |
| 73 | void led(bool on); |
| 74 | void panic(void); |
| 75 | |
| 76 | uint64_t timer_read(void); |
| 77 | void timer_init(void); |
| 78 | |
| 79 | bool gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res); |
| 80 | void gpio_cleanup(void); |
| 81 | |
| 82 | void get_sernum(void); |
| 83 | |
| 84 | void board_app_init(void); |
| 85 | |
| 86 | #endif /* !BOARD_H */ |
| 87 | |
