| // Set up the pool of audio data blocks | // Set up the pool of audio data blocks | ||||
| // placing them all onto the free list | // placing them all onto the free list | ||||
| __attribute__((section(".progmem"))) | |||||
| void AudioStream::initialize_memory(audio_block_t *data, unsigned int num) | |||||
| FLASHMEM void AudioStream::initialize_memory(audio_block_t *data, unsigned int num) | |||||
| { | { | ||||
| unsigned int i; | unsigned int i; | ||||
| unsigned int maxnum = MAX_AUDIO_MEMORY / AUDIO_BLOCK_SAMPLES / 2; | unsigned int maxnum = MAX_AUDIO_MEMORY / AUDIO_BLOCK_SAMPLES / 2; |
| #include "imxrt.h" | #include "imxrt.h" | ||||
| #include "core_pins.h" | #include "core_pins.h" | ||||
| #include "debug/printf.h" | #include "debug/printf.h" | ||||
| #include "avr/pgmspace.h" | |||||
| static uint8_t calibrating; | static uint8_t calibrating; | ||||
| static uint8_t analog_config_bits = 10; | static uint8_t analog_config_bits = 10; | ||||
| #define MAX_ADC_CLOCK 20000000 | #define MAX_ADC_CLOCK 20000000 | ||||
| __attribute__((section(".progmem"))) | |||||
| void analog_init(void) | |||||
| FLASHMEM void analog_init(void) | |||||
| { | { | ||||
| uint32_t mode, avg=0; | uint32_t mode, avg=0; | ||||
| #ifdef PRINT_DEBUG_STUFF | #ifdef PRINT_DEBUG_STUFF | ||||
| #include "avr/pgmspace.h" | |||||
| #include <stdarg.h> | #include <stdarg.h> | ||||
| #include "imxrt.h" | #include "imxrt.h" | ||||
| static void puint_debug(unsigned int num); | static void puint_debug(unsigned int num); | ||||
| __attribute__((section(".progmem"))) | |||||
| void printf_debug(const char *format, ...) | |||||
| FLASHMEM void printf_debug(const char *format, ...) | |||||
| { | { | ||||
| va_list args; | va_list args; | ||||
| unsigned int val; | unsigned int val; | ||||
| printf_debug(buf + i); | printf_debug(buf + i); | ||||
| } | } | ||||
| __attribute__((section(".progmem"))) | |||||
| void putchar_debug(char c) | |||||
| FLASHMEM void putchar_debug(char c) | |||||
| { | { | ||||
| while (!(LPUART3_STAT & LPUART_STAT_TDRE)) ; // wait | while (!(LPUART3_STAT & LPUART_STAT_TDRE)) ; // wait | ||||
| LPUART3_DATA = c; | LPUART3_DATA = c; | ||||
| } | } | ||||
| __attribute__((section(".progmem"))) | |||||
| void printf_debug_init(void) | |||||
| FLASHMEM void printf_debug_init(void) | |||||
| { | { | ||||
| CCM_CCGR0 |= CCM_CCGR0_LPUART3(CCM_CCGR_ON); // turn on Serial4 | CCM_CCGR0 |= CCM_CCGR0_LPUART3(CCM_CCGR_ON); // turn on Serial4 | ||||
| IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_06 = 2; // Arduino pin 17 | IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_06 = 2; // Arduino pin 17 |
| #include "imxrt.h" | #include "imxrt.h" | ||||
| #include "wiring.h" | #include "wiring.h" | ||||
| #include "usb_dev.h" | #include "usb_dev.h" | ||||
| #include "avr/pgmspace.h" | |||||
| #include "debug/printf.h" | #include "debug/printf.h" | ||||
| #define SIZE_64M (SCB_MPU_RASR_SIZE(25) | SCB_MPU_RASR_ENABLE) | #define SIZE_64M (SCB_MPU_RASR_SIZE(25) | SCB_MPU_RASR_ENABLE) | ||||
| #define REGION(n) (SCB_MPU_RBAR_REGION(n) | SCB_MPU_RBAR_VALID) | #define REGION(n) (SCB_MPU_RBAR_REGION(n) | SCB_MPU_RBAR_VALID) | ||||
| __attribute__((section(".progmem"))) | |||||
| void configure_cache(void) | |||||
| FLASHMEM void configure_cache(void) | |||||
| { | { | ||||
| //printf("MPU_TYPE = %08lX\n", SCB_MPU_TYPE); | //printf("MPU_TYPE = %08lX\n", SCB_MPU_TYPE); | ||||
| //printf("CCR = %08lX\n", SCB_CCR); | //printf("CCR = %08lX\n", SCB_CCR); | ||||
| } | } | ||||
| __attribute__((section(".progmem"))) | |||||
| void usb_pll_start() | |||||
| FLASHMEM void usb_pll_start() | |||||
| { | { | ||||
| while (1) { | while (1) { | ||||
| uint32_t n = CCM_ANALOG_PLL_USB1; // pg 759 | uint32_t n = CCM_ANALOG_PLL_USB1; // pg 759 | ||||
| } | } | ||||
| } | } | ||||
| __attribute__((section(".progmem"))) | |||||
| void reset_PFD() | |||||
| FLASHMEM void reset_PFD() | |||||
| { | { | ||||
| //Reset PLL2 PFDs, set default frequencies: | //Reset PLL2 PFDs, set default frequencies: | ||||
| CCM_ANALOG_PFD_528_SET = (1 << 31) | (1 << 23) | (1 << 15) | (1 << 7); | CCM_ANALOG_PFD_528_SET = (1 << 31) | (1 << 23) | (1 << 15) | (1 << 7); |
| #include "imxrt.h" | #include "imxrt.h" | ||||
| #include "core_pins.h" | #include "core_pins.h" | ||||
| #include "avr/pgmspace.h" | |||||
| #include "debug/printf.h" | #include "debug/printf.h" | ||||
| static uint32_t s_hotTemp, s_hotCount, s_roomC_hotC; | static uint32_t s_hotTemp, s_hotCount, s_roomC_hotC; | ||||
| static float s_hot_ROOM; | static float s_hot_ROOM; | ||||
| __attribute__((section(".progmem"))) | |||||
| void tempmon_init(void) | |||||
| FLASHMEM void tempmon_init(void) | |||||
| { | { | ||||
| // Notes: | // Notes: | ||||
| // TEMPMON_TEMPSENSE0 &= ~0x2U; Stops temp monitoring | // TEMPMON_TEMPSENSE0 &= ~0x2U; Stops temp monitoring |
| #include "usb_desc.h" | #include "usb_desc.h" | ||||
| #include "usb_serial.h" | #include "usb_serial.h" | ||||
| #include "core_pins.h" // for delay() | #include "core_pins.h" // for delay() | ||||
| #include "avr/pgmspace.h" | |||||
| #include <string.h> | #include <string.h> | ||||
| #include "debug/printf.h" | #include "debug/printf.h" | ||||
| static void run_callbacks(endpoint_t *ep); | static void run_callbacks(endpoint_t *ep); | ||||
| __attribute__((section(".progmem"))) | |||||
| void usb_init(void) | |||||
| FLASHMEM void usb_init(void) | |||||
| { | { | ||||
| // TODO: only enable when VBUS detected | // TODO: only enable when VBUS detected | ||||
| // TODO: return to low power mode when VBUS removed | // TODO: return to low power mode when VBUS removed |