android/app/jni/extern/pwrnoise/pwrnoise.h
raw| 1 | #ifndef PWRNOISE_H |
| 2 | #define PWRNOISE_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | #include <stdint.h> |
| 9 | #include <stdbool.h> |
| 10 | |
| 11 | typedef struct { |
| 12 | bool enable; |
| 13 | bool am; |
| 14 | |
| 15 | uint16_t period; |
| 16 | uint16_t period_counter; |
| 17 | |
| 18 | uint8_t octave; |
| 19 | uint16_t octave_counter; |
| 20 | |
| 21 | uint8_t tapa; |
| 22 | uint8_t tapb; |
| 23 | bool tapb_enable; |
| 24 | |
| 25 | uint16_t lfsr; |
| 26 | uint8_t vol; |
| 27 | |
| 28 | uint8_t out_latch; |
| 29 | uint8_t prev; |
| 30 | } noise_channel_t; |
| 31 | |
| 32 | typedef struct { |
| 33 | bool enable; |
| 34 | uint8_t flags; |
| 35 | |
| 36 | uint16_t period; |
| 37 | uint16_t period_counter; |
| 38 | |
| 39 | uint8_t octave; |
| 40 | uint16_t octave_counter; |
| 41 | |
| 42 | uint8_t alength; |
| 43 | uint8_t blength; |
| 44 | uint16_t a; |
| 45 | uint16_t b; |
| 46 | bool portion; |
| 47 | |
| 48 | uint8_t aoffset; |
| 49 | uint8_t boffset; |
| 50 | |
| 51 | uint8_t accum; |
| 52 | uint8_t vol; |
| 53 | |
| 54 | uint8_t out_latch; |
| 55 | uint8_t prev; |
| 56 | } slope_channel_t; |
| 57 | |
| 58 | typedef struct { |
| 59 | uint8_t flags; |
| 60 | uint8_t gpioa; |
| 61 | uint8_t gpiob; |
| 62 | |
| 63 | noise_channel_t n1; |
| 64 | noise_channel_t n2; |
| 65 | noise_channel_t n3; |
| 66 | slope_channel_t s; |
| 67 | } power_noise_t; |
| 68 | |
| 69 | void pwrnoise_reset(power_noise_t *pn); |
| 70 | void pwrnoise_step(power_noise_t *pn, uint16_t cycles, int16_t *left, int16_t *right); |
| 71 | void pwrnoise_write(power_noise_t *pn, uint8_t reg, uint8_t val); |
| 72 | |
| 73 | #ifdef __cplusplus |
| 74 | } |
| 75 | #endif |
| 76 | |
| 77 | #endif |