mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-14 20:03:44 +00:00
aee54e5b2d
* update hackrf submodule
* add platform_gpio.c and platform_scu.c to baseband build
-New source files required by the updated hackrf submodule.
* adapt scsi.c to updated hackrf API
-Rename struct gpio_t to struct gpio and add gpio_lpc.h include.
* adapt hackrf_core.c to updated hackrf API
- Rename struct gpio_t to struct gpio throughout
- Add platform_gpio.h, platform_scu.h, and fixed_point.h includes
- Update pin_setup() to use platform_scu() accessor instead of SCU_ macros
- Rewrite sample_rate_set() to use new fixed-point frequency API
- Update ssp_config_w25q80bv for changed struct layout
- Update si5351c and max283x function call signatures
58 lines
1.0 KiB
C
58 lines
1.0 KiB
C
#include "gpio_lpc.h"
|
|
#include "gpio.h"
|
|
|
|
typedef enum {
|
|
LED1 = 0,
|
|
LED2 = 1,
|
|
LED3 = 2,
|
|
LED4 = 3,
|
|
} led_t;
|
|
|
|
/* GPIO Output PinMux */
|
|
static struct gpio gpio_led[] = {
|
|
GPIO(2, 1),
|
|
GPIO(2, 2),
|
|
GPIO(2, 8),
|
|
#ifdef RAD1O
|
|
GPIO(5, 26),
|
|
#endif
|
|
};
|
|
|
|
void delay(uint32_t duration) {
|
|
while (duration--) {
|
|
/* cannot be optimized out */
|
|
__asm__ volatile("nop");
|
|
}
|
|
}
|
|
|
|
void delay_us_at_mhz(uint32_t us, uint32_t mhz) {
|
|
/* overflow-safe multiply */
|
|
uint64_t cycles64 = (uint64_t)us * (uint64_t)mhz;
|
|
if (cycles64 > UINT32_MAX) {
|
|
cycles64 = UINT32_MAX;
|
|
}
|
|
delay((uint32_t)cycles64);
|
|
}
|
|
|
|
void led_on(const led_t led) {
|
|
gpio_set(&gpio_led[led]);
|
|
}
|
|
|
|
void led_off(const led_t led) {
|
|
gpio_clear(&gpio_led[led]);
|
|
}
|
|
|
|
void halt_and_flash(const uint32_t duration) {
|
|
/* blink LED1, LED2, and LED3 */
|
|
while (1) {
|
|
led_on(LED1);
|
|
led_on(LED2);
|
|
led_on(LED3);
|
|
delay(duration);
|
|
led_off(LED1);
|
|
led_off(LED2);
|
|
led_off(LED3);
|
|
delay(duration);
|
|
}
|
|
}
|