/* Copyright 2017 fishpepper gmail.com 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 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . author: fishpepper gmail.com */ #include "hal_io.h" #include "hal_cc25xx.h" #include "delay.h" #include #include #include #include #include #include #define BLOCK_SIZE (4*1024) // I/O access volatile static unsigned *gpio; // GPIO setup macros. Always use INP_GPIO(x) before using OUT_GPIO(x) or SET_GPIO_ALT(x,y) #define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7 << (((g) % 10)*3)) #define OUT_GPIO(g) *(gpio+((g)/10)) |= (1 << (((g)% 10)*3)) #define SET_GPIO_ALT(g, a) *(gpio+(((g)/10))) |= \ (((a) <= 3 ? (a) + 4:(a) == 4 ? 3 : 2) << (((g) % 10) * 3)) #define GPIO_SET *(gpio + 7) // sets bits which are 1 ignores bits which are 0 #define GPIO_CLR *(gpio + 10) // clears bits which are 1 ignores bits which are 0 #define GET_GPIO(g) (*(gpio + 13) & (1 << g)) // 0 if LOW, (1<