You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.4 KiB
35 lines
1.4 KiB
4 years ago
|
#include "quantum.h"
|
||
|
|
||
|
/* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */
|
||
|
|
||
|
#ifndef NOP_FUDGE
|
||
|
# if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX)
|
||
|
# define NOP_FUDGE 0.4
|
||
|
# else
|
||
|
# error("NOP_FUDGE configuration required")
|
||
|
# define NOP_FUDGE 1 // this just pleases the compile so the above error is easier to spot
|
||
|
# endif
|
||
|
#endif
|
||
|
|
||
|
#define NUMBER_NOPS 6
|
||
|
#define CYCLES_PER_SEC (STM32_SYSCLK / NUMBER_NOPS * NOP_FUDGE)
|
||
|
#define NS_PER_SEC (1000000000L) // Note that this has to be SIGNED since we want to be able to check for negative values of derivatives
|
||
|
#define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC)
|
||
|
#define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE)
|
||
|
|
||
|
#define wait_ns(x) \
|
||
|
do { \
|
||
|
for (int i = 0; i < NS_TO_CYCLES(x); i++) { \
|
||
|
__asm__ volatile("nop\n\t" \
|
||
|
"nop\n\t" \
|
||
|
"nop\n\t" \
|
||
|
"nop\n\t" \
|
||
|
"nop\n\t" \
|
||
|
"nop\n\t"); \
|
||
|
} \
|
||
|
} while (0)
|
||
|
|
||
|
|
||
|
void gamecube_init(void);
|
||
|
void gamecube_scan(uint16_t * buttons, uint8_t * joysticks);
|