diff --git a/Makefile b/Makefile index 1094e23..16f0ced 100644 --- a/Makefile +++ b/Makefile @@ -93,6 +93,7 @@ SRC = main.c \ $(HALS)/stm32f7xx_hal_pwr.c \ $(HALS)/stm32f7xx_hal_pwr_ex.c \ $(HALS)/stm32f7xx_hal_rng.c \ + $(HALS)/stm32f7xx_hal_sai.c \ $(HALS)/stm32f7xx_hal_spi.c \ $(HALS)/stm32f7xx_hal_tim.c \ $(HALS)/stm32f7xx_hal_tim_ex.c \ diff --git a/lib/flash.h b/lib/flash.h index 645f2ef..a1890a5 100644 --- a/lib/flash.h +++ b/lib/flash.h @@ -2,17 +2,17 @@ #include "stm32f7xx.h" -// 16kB calibration -#define CALIBRATION_LOCATION 0x0800C000 -#define CALIBRATION_SECTOR FLASH_SECTOR_3 -#define CALIBRATION_SIZE (0x4000 - 4) - -// 64kB user script -#define USER_SCRIPT_LOCATION 0x08010000 -#define USER_SCRIPT_SECTOR FLASH_SECTOR_4 +// 16kB calibration -> using 256kB +#define CALIBRATION_LOCATION 0x08180000 +#define CALIBRATION_SECTOR FLASH_SECTOR_10 // UNUSED +#define CALIBRATION_SIZE (0x40000 - 4) + +// 64kB user script -> using 256kB +#define USER_SCRIPT_LOCATION 0x081C0000 +#define USER_SCRIPT_SECTOR FLASH_SECTOR_11 //#define USER_SCRIPT_SIZE (0x10000 - 4) // #define USER_SCRIPT_SIZE (0x2000 - 4) // 8kB up to v2.1 -#define USER_SCRIPT_SIZE (0x4000 - 4) // 16kB v3.0+ +#define USER_SCRIPT_SIZE (0x40000 - 4) // 16kB v3.0+ typedef enum { FLASH_Status_Init = 0 , FLASH_Status_Saved = 1 diff --git a/lib/slopes.h b/lib/slopes.h index 6ad7b8b..dd8ef2c 100644 --- a/lib/slopes.h +++ b/lib/slopes.h @@ -39,7 +39,7 @@ typedef struct{ float shaped; // current shaped output voltage } Slope_t; -#define SLOPE_CHANNELS 4 +#define SLOPE_CHANNELS 8 // refactor for dynamic SLOPE_CHANNELS // refactor for dynamic SAMPLE_RATE diff --git a/ll/adda.c b/ll/adda.c index fb7647e..20558f3 100644 --- a/ll/adda.c +++ b/ll/adda.c @@ -5,7 +5,8 @@ #include "debug_pin.h" #include "ads131.h" -#include "dac8565.h" +// #include "dac8565.h" +#include "dac108.h" #include "../lib/flash.h" // FLASH_*_t #include "cal_ll.h" // CAL_LL_Init(), @@ -28,15 +29,15 @@ static void CAL_ReadFlash( void ); uint16_t ADDA_Init( int adc_timer_ix ) { - ADC_Init( ADDA_BLOCK_SIZE - , ADDA_ADC_CHAN_COUNT - , adc_timer_ix - ); + // ADC_Init( ADDA_BLOCK_SIZE + // , ADDA_ADC_CHAN_COUNT + // , adc_timer_ix + // ); DAC_Init( ADDA_BLOCK_SIZE , ADDA_DAC_CHAN_COUNT ); - CAL_LL_Init(); - CAL_ReadFlash(); + // CAL_LL_Init(); + // CAL_ReadFlash(); return ADDA_BLOCK_SIZE; } @@ -45,12 +46,12 @@ void ADDA_Start( void ) DAC_Start(); } -void ADDA_BlockProcess( uint32_t* dac_pickle_ptr ) +static IO_block_t b = { .size = ADDA_BLOCK_SIZE }; +void ADDA_BlockProcess( uint16_t* dac_pickle_ptr ) { - IO_block_t b = { .size = ADDA_BLOCK_SIZE }; - ADC_UnpickleBlock( b.in[0] - , ADDA_BLOCK_SIZE - ); + // ADC_UnpickleBlock( b.in[0] + // , ADDA_BLOCK_SIZE + // ); IO_BlockProcess( &b ); DAC_PickleBlock( dac_pickle_ptr , b.out[0] @@ -60,16 +61,16 @@ void ADDA_BlockProcess( uint32_t* dac_pickle_ptr ) float ADDA_GetADCValue( uint8_t channel ) { - return ADC_GetValue( channel ); + return 0.0; + // return ADC_GetValue( channel ); } __weak IO_block_t* IO_BlockProcess( IO_block_t* b ) { for( uint16_t i=0; i<(b->size); i++ ){ - b->out[0][i] = b->in[0][i]; - b->out[1][i] = b->in[1][i]; - b->out[2][i] = 2.0; - b->out[3][i] = 3.0; + for(int j=0; j<8; j++){ + b->out[j][i] = 0.0; + } } return b; } @@ -98,10 +99,10 @@ void CAL_Set( int chan, CAL_Param_t param, float val ) if(chan >= 1 && chan <= 2){ // adc if(param == CAL_Offset){ cal.adc[chan-1].shift = val; - ADC_CalibrateShift(chan-1, val); + // ADC_CalibrateShift(chan-1, val); } else { cal.adc[chan-1].scale = val; - ADC_CalibrateScalar(chan-1, val); + // ADC_CalibrateScalar(chan-1, val); } } else if( chan >= 3 && chan <= 6){ // dac if(param == CAL_Offset){ @@ -145,8 +146,9 @@ static void CAL_ReadFlash( void ) , sizeof(CAL_chan_t) * (2+4) ) ){ for( int j=0; j<2; j++ ){ - ADC_CalibrateShift( j, cal.adc[j].shift ); - ADC_CalibrateScalar( j, cal.adc[j].scale ); + ;; + // ADC_CalibrateShift( j, cal.adc[j].shift ); + // ADC_CalibrateScalar( j, cal.adc[j].scale ); } for( int j=0; j<4; j++ ){ DAC_CalibrateOffset( j, cal.dac[j].shift ); @@ -154,6 +156,6 @@ static void CAL_ReadFlash( void ) } } else { printf("not yet calibrated\n"); - CAL_Defaults(); + // CAL_Defaults(); } } diff --git a/ll/dac108.c b/ll/dac108.c index 9c1797b..f62a2d2 100644 --- a/ll/dac108.c +++ b/ll/dac108.c @@ -15,7 +15,7 @@ uint16_t* samples = NULL; #define DAC_ZERO_VOLTS ((uint16_t)(((uint32_t)0xFFFF * 2)/3)) #define DAC_V_TO_U16 ((float)(65535.0 / 15.0)) -#define DAC_CHANNELSS 4 +#define DAC_CHANNELSS 8 float dac_calibrated_offset[DAC_CHANNELSS]; float dac_calibrated_scalar[DAC_CHANNELSS]; @@ -26,15 +26,16 @@ void DAC_Init(uint16_t bsize, uint8_t chan_count){ sai_init(); // Create the sample buffer for DMA transfer - samp_count = DAC_BUFFER_COUNT * bsize * chan_count; - samples = malloc( sizeof(uint16_t) * samp_count ); - for( int i=0; iErrorCode); +} diff --git a/ll/dac108.h b/ll/dac108.h index befc88e..507b317 100644 --- a/ll/dac108.h +++ b/ll/dac108.h @@ -3,53 +3,6 @@ #include #include "interrupts.h" // DAC_IRQPriority -// Defn for I2S -#define I2Sx SPI2 -#define I2Sx_CLK_ENABLE() __HAL_RCC_SPI2_CLK_ENABLE() -#define I2Sx_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() -#define I2Sx_NSS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define I2Sx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define I2Sx_MOSI_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define I2Sx_NRST_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() - -#define I2Sx_FORCE_RESET() __HAL_RCC_SPI2_FORCE_RESET() -#define I2Sx_RELEASE_RESET() __HAL_RCC_SPI2_RELEASE_RESET() - -// Definition for I2Sx Pins -#define I2Sx_NSS_PIN GPIO_PIN_12 -#define I2Sx_NSS_GPIO_PORT GPIOB -#define I2Sx_NSS_AF GPIO_AF5_SPI2 -#define I2Sx_SCK_PIN GPIO_PIN_13 -#define I2Sx_SCK_GPIO_PORT GPIOB -#define I2Sx_SCK_AF GPIO_AF5_SPI2 -#define I2Sx_MOSI_PIN GPIO_PIN_15 -#define I2Sx_MOSI_GPIO_PORT GPIOB -#define I2Sx_MOSI_AF GPIO_AF5_SPI2 -#define I2Sx_NRST_PIN GPIO_PIN_14 -#define I2Sx_NRST_GPIO_PORT GPIOB - -// Definition for SPId's DMA -#define I2Sx_TX_DMA_CHANNEL DMA_CHANNEL_0 -#define I2Sx_TX_DMA_STREAM DMA1_Stream4 - -// Definition for SPId's NVIC -#define I2Sx_IRQn SPI2_IRQn -#define I2Sx_IRQHandler SPI2_IRQHandler -#define I2Sx_DMA_TX_IRQn DMA1_Stream4_IRQn -#define I2Sx_DMA_TX_IRQHandler DMA1_Stream4_IRQHandler - -#define I2Sx_IRQPriority DAC_IRQPriority -#define I2Sx_IRQSubPriority 2 -#define I2Sx_DMA_TX_IRQPriority DAC_IRQPriority -#define I2Sx_DMA_TX_IRQSubPriority 1 - -// dac8565 defines -#define DAC8565_SET_ONE ((uint8_t)0b00010000) -#define DAC8565_PREP_ONE ((uint8_t)0x0) -#define DAC8565_SET_AND_UPDATE ((uint8_t)0b00100000) -#define DAC8565_SET_ALL ((uint8_t)0b00110100) -#define DAC8565_REFRESH_ALL ((uint8_t)0b00110000) - void DAC_Init( uint16_t bsize, uint8_t chan_count ); void DAC_Start(void); @@ -60,13 +13,6 @@ void DAC_PickleBlock( uint16_t* dac_pickle_ptr , uint16_t bsize ); -void I2Sx_DMA_TX_IRQHandler(void); -void I2Sx_IRQHandler(void); - -void HAL_I2S_TxCpltCallback( I2S_HandleTypeDef *hi2s ); -void HAL_I2S_TxHalfCpltCallback( I2S_HandleTypeDef *hi2s ); -void HAL_I2S_ErrorCallback( I2S_HandleTypeDef *hi2s ); - void DAC_I2S_MspInit(I2S_HandleTypeDef *hi2s); void DAC_I2S_MspDeInit(I2S_HandleTypeDef *hi2s); @@ -78,3 +24,4 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai); void DMA2_Stream3_IRQHandler(void); void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai); void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai); +void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai); diff --git a/ll/dac8565.c b/ll/dac8565.c deleted file mode 100644 index ce2a704..0000000 --- a/ll/dac8565.c +++ /dev/null @@ -1,284 +0,0 @@ -/*#include "dac8565.h" - -#include -#include "stdlib.h" // malloc() -#include "debug_pin.h" - -#include "adda.h" // ADDA_BlockProcess() -#include "wrMath.h" // lim_f() - -#define DAC_BUFFER_COUNT 2 // ping-pong - -I2S_HandleTypeDef dac_i2s; - -// pointer to the malloc()d buffer from DAC_Init() -uint32_t samp_count = 0; -uint32_t* samples = NULL; - -#define DAC_ZERO_VOLTS ((uint16_t)(((uint32_t)0xFFFF * 2)/3)) -#define DAC_V_TO_U16 ((float)(65535.0 / 15.0)) -#define DAC_CHANNELSS 4 -float dac_calibrated_offset[DAC_CHANNELSS]; -float dac_calibrated_scalar[DAC_CHANNELSS]; - -void DAC_Init( uint16_t bsize, uint8_t chan_count ) -{ - // Create the sample buffer for DMA transfer - samp_count = DAC_BUFFER_COUNT * bsize * chan_count; - samples = malloc( sizeof(uint32_t) * samp_count ); - for( int i=0; i (int32_t)(uint16_t)0xFFFF) ? 0xFFFF : (v < (int32_t)0) ? 0 : v; -} - -// does all the work converting a generic representation into serial packets -// convert floats (representing volts) to u16 representation -// Interleave a block of each channel into a stream - -void DAC_PickleBlock( uint32_t* dac_pickle_ptr - , float* unpickled_data - , uint16_t bsize - ) -{ - for( uint8_t j=0; j<4; j++ ){ - add_vf_f( &(unpickled_data[j*bsize]) - , dac_calibrated_offset[j] - , &(unpickled_data[j*bsize]) - , bsize - ); - } - for( uint8_t j=0; j<4; j++ ){ - mul_vf_f( &(unpickled_data[j*bsize]) - , dac_calibrated_scalar[j] // scale volts up to u16 - , bsize - ); - } - - uint16_t usixteens[bsize * 4]; - uint16_t* usixp = usixteens; - - for( uint16_t i=0; i>8; - insert_p += 3; - *insert_p++ = *usixp++ & 0xFF; - } -} - - - -// This wraps the (un)pickling functions in ll/addac.c -void HAL_I2S_TxHalfCpltCallback( I2S_HandleTypeDef *hi2s ) -{ - Debug_Pin_Set(1); - ADDA_BlockProcess( samples ); - Debug_Pin_Set(0); -} -void HAL_I2S_TxCpltCallback( I2S_HandleTypeDef *hi2s ) -{ - Debug_Pin_Set(1); - ADDA_BlockProcess( &samples[samp_count/2] ); - Debug_Pin_Set(0); -} -void HAL_I2S_ErrorCallback( I2S_HandleTypeDef *hi2s ) -{ - printf("i2s_tx_error\n"); -} - - -// Driver Config -void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s) -{ - // I2S PLL Config - RCC_PeriphCLKInitTypeDef RCC_ExCLKInitStruct; - - // PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLM) - // I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR - RCC_ExCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - RCC_ExCLKInitStruct.I2sClockSelection = RCC_I2SCLKSOURCE_PLLI2S; - RCC_ExCLKInitStruct.PLLI2S.PLLI2SN = 384; // mul factor: 50~432 - RCC_ExCLKInitStruct.PLLI2S.PLLI2SR = 2; // div factor: 2~7 - HAL_RCCEx_PeriphCLKConfig(&RCC_ExCLKInitStruct); - - // SPI/I2S & DMA - I2Sx_CLK_ENABLE(); - I2Sx_DMAx_CLK_ENABLE(); - - // GPIO pins - I2Sx_NSS_GPIO_CLK_ENABLE(); - I2Sx_SCK_GPIO_CLK_ENABLE(); - I2Sx_MOSI_GPIO_CLK_ENABLE(); - I2Sx_NRST_GPIO_CLK_ENABLE(); - - GPIO_InitTypeDef GPIO_InitStruct; - - GPIO_InitStruct.Pin = I2Sx_SCK_PIN; - GPIO_InitStruct.Speed = GPIO_SPEED_FAST; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Alternate = I2Sx_SCK_AF; - HAL_GPIO_Init(I2Sx_SCK_GPIO_PORT, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = I2Sx_MOSI_PIN; - GPIO_InitStruct.Alternate = I2Sx_MOSI_AF; - HAL_GPIO_Init(I2Sx_MOSI_GPIO_PORT, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = I2Sx_NSS_PIN; - GPIO_InitStruct.Alternate = I2Sx_NSS_AF; - HAL_GPIO_Init(I2Sx_NSS_GPIO_PORT, &GPIO_InitStruct); - - // NRST handled manually - GPIO_InitStruct.Pin = I2Sx_NRST_PIN; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - HAL_GPIO_Init(I2Sx_NRST_GPIO_PORT, &GPIO_InitStruct); - - // DMA Streams - static DMA_HandleTypeDef hdma_tx; - - hdma_tx.Instance = I2Sx_TX_DMA_STREAM; - - hdma_tx.Init.Channel = I2Sx_TX_DMA_CHANNEL; - hdma_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; - hdma_tx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_tx.Init.Mode = DMA_CIRCULAR; - hdma_tx.Init.Priority = DMA_PRIORITY_LOW; - hdma_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - hdma_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_tx.Init.MemBurst = DMA_MBURST_INC4; - hdma_tx.Init.PeriphBurst = DMA_PBURST_INC4; - - HAL_DMA_Init(&hdma_tx); - - // Associate I2S w/ DMA - __HAL_LINKDMA(hi2s, hdmatx, hdma_tx); - - // DMA Priority (should be below IO, but above main process) - HAL_NVIC_SetPriority( I2Sx_DMA_TX_IRQn - , I2Sx_DMA_TX_IRQPriority - , I2Sx_DMA_TX_IRQSubPriority - ); - HAL_NVIC_EnableIRQ( I2Sx_DMA_TX_IRQn ); - - // Must be lower priority than the above DMA - HAL_NVIC_SetPriority( I2Sx_IRQn - , I2Sx_IRQPriority - , I2Sx_IRQSubPriority - ); - HAL_NVIC_EnableIRQ( I2Sx_IRQn ); -} - -void DAC_I2S_MspDeInit(I2S_HandleTypeDef *hi2s) -{ - - static DMA_HandleTypeDef hdma_tx; - - I2Sx_FORCE_RESET(); - I2Sx_RELEASE_RESET(); - - HAL_GPIO_DeInit(I2Sx_NSS_GPIO_PORT, I2Sx_NSS_PIN); - HAL_GPIO_DeInit(I2Sx_SCK_GPIO_PORT, I2Sx_SCK_PIN); - HAL_GPIO_DeInit(I2Sx_MOSI_GPIO_PORT, I2Sx_MOSI_PIN); - - HAL_DMA_DeInit(&hdma_tx); - - HAL_NVIC_DisableIRQ(I2Sx_DMA_TX_IRQn); - HAL_NVIC_DisableIRQ(I2Sx_IRQn); -} - -void I2Sx_DMA_TX_IRQHandler(void) -{ - HAL_DMA_IRQHandler(dac_i2s.hdmatx); -} -void I2Sx_IRQHandler(void) -{ - HAL_I2S_IRQHandler(&dac_i2s); -} - -*/ diff --git a/ll/dac8565.h b/ll/dac8565.h deleted file mode 100644 index 8fbe45f..0000000 --- a/ll/dac8565.h +++ /dev/null @@ -1,74 +0,0 @@ -#pragma once - -/* -#include -#include "interrupts.h" // DAC_IRQPriority - -// Defn for I2S -#define I2Sx SPI2 -#define I2Sx_CLK_ENABLE() __HAL_RCC_SPI2_CLK_ENABLE() -#define I2Sx_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() -#define I2Sx_NSS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define I2Sx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define I2Sx_MOSI_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define I2Sx_NRST_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() - -#define I2Sx_FORCE_RESET() __HAL_RCC_SPI2_FORCE_RESET() -#define I2Sx_RELEASE_RESET() __HAL_RCC_SPI2_RELEASE_RESET() - -// Definition for I2Sx Pins -#define I2Sx_NSS_PIN GPIO_PIN_12 -#define I2Sx_NSS_GPIO_PORT GPIOB -#define I2Sx_NSS_AF GPIO_AF5_SPI2 -#define I2Sx_SCK_PIN GPIO_PIN_13 -#define I2Sx_SCK_GPIO_PORT GPIOB -#define I2Sx_SCK_AF GPIO_AF5_SPI2 -#define I2Sx_MOSI_PIN GPIO_PIN_15 -#define I2Sx_MOSI_GPIO_PORT GPIOB -#define I2Sx_MOSI_AF GPIO_AF5_SPI2 -#define I2Sx_NRST_PIN GPIO_PIN_14 -#define I2Sx_NRST_GPIO_PORT GPIOB - -// Definition for SPId's DMA -#define I2Sx_TX_DMA_CHANNEL DMA_CHANNEL_0 -#define I2Sx_TX_DMA_STREAM DMA1_Stream4 - -// Definition for SPId's NVIC -#define I2Sx_IRQn SPI2_IRQn -#define I2Sx_IRQHandler SPI2_IRQHandler -#define I2Sx_DMA_TX_IRQn DMA1_Stream4_IRQn -#define I2Sx_DMA_TX_IRQHandler DMA1_Stream4_IRQHandler - -#define I2Sx_IRQPriority DAC_IRQPriority -#define I2Sx_IRQSubPriority 2 -#define I2Sx_DMA_TX_IRQPriority DAC_IRQPriority -#define I2Sx_DMA_TX_IRQSubPriority 1 - -// dac8565 defines -#define DAC8565_SET_ONE ((uint8_t)0b00010000) -#define DAC8565_PREP_ONE ((uint8_t)0x0) -#define DAC8565_SET_AND_UPDATE ((uint8_t)0b00100000) -#define DAC8565_SET_ALL ((uint8_t)0b00110100) -#define DAC8565_REFRESH_ALL ((uint8_t)0b00110000) - -void DAC_Init( uint16_t bsize, uint8_t chan_count ); -void DAC_Start(void); - -void DAC_CalibrateScalar( uint8_t channel, float scale ); -void DAC_CalibrateOffset( uint8_t channel, float volts ); -void DAC_PickleBlock( uint32_t* dac_pickle_ptr - , float* unpickled_data - , uint16_t bsize - ); - -void I2Sx_DMA_TX_IRQHandler(void); -void I2Sx_IRQHandler(void); - -void HAL_I2S_TxCpltCallback( I2S_HandleTypeDef *hi2s ); -void HAL_I2S_TxHalfCpltCallback( I2S_HandleTypeDef *hi2s ); -void HAL_I2S_ErrorCallback( I2S_HandleTypeDef *hi2s ); - -void DAC_I2S_MspInit(I2S_HandleTypeDef *hi2s); -void DAC_I2S_MspDeInit(I2S_HandleTypeDef *hi2s); - -*/ diff --git a/ll/system.c b/ll/system.c index 2e590ad..da7fe33 100644 --- a/ll/system.c +++ b/ll/system.c @@ -106,9 +106,9 @@ static void MPU_Config(void) // Configure the MPU attributes as WT for SRAM mpu.Enable = MPU_REGION_ENABLE; // mpu.Enable = MPU_REGION_DISABLE; - // mpu.BaseAddress = 0x20020000; - mpu.BaseAddress = 0x20000000; - mpu.Size = MPU_REGION_SIZE_512KB; + mpu.BaseAddress = 0x20020000; + // mpu.BaseAddress = 0x20000000; + mpu.Size = MPU_REGION_SIZE_256KB; mpu.AccessPermission = MPU_REGION_FULL_ACCESS; mpu.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; mpu.IsCacheable = MPU_ACCESS_CACHEABLE; diff --git a/main.c b/main.c index b52099e..92044c8 100755 --- a/main.c +++ b/main.c @@ -41,8 +41,8 @@ int main(void) // Drivers int max_timers = Timer_Init(); - // IO_Init( max_timers-2 ); // use second-last timer - // IO_Start(); // must start IO before running lua init() script + IO_Init( max_timers-2 ); // use second-last timer + IO_Start(); // must start IO before running lua init() script events_init(); Metro_Init( max_timers-2 ); // reserve 2 timers for USB & ADC clock_init( 100 ); // TODO how to pass it the timer? diff --git a/stm32_flash.ld b/stm32_flash.ld index 20465f2..a4cc30e 100755 --- a/stm32_flash.ld +++ b/stm32_flash.ld @@ -34,7 +34,7 @@ ENTRY(Reset_Handler) _estack = 0x20080000; /* end of 512K RAM */ /* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Heap_Size = 0x1000; /* required amount of heap */ _Min_Stack_Size = 0x10000; /* required amount of stack */ /* Specify the memory areas */ diff --git a/usbd/usbd_main.c b/usbd/usbd_main.c index fc73781..f018a7b 100755 --- a/usbd/usbd_main.c +++ b/usbd/usbd_main.c @@ -43,9 +43,9 @@ void OTG_HS_IRQHandler(void) HAL_PCD_IRQHandler(&hpcd); } -extern TIM_HandleTypeDef USBTimHandle; +// extern TIM_HandleTypeDef USBTimHandle; -void TIMu_IRQHandler(void) -{ - HAL_TIM_IRQHandler(&USBTimHandle); -} +// void TIMu_IRQHandler(void) +// { +// HAL_TIM_IRQHandler(&USBTimHandle); +// }