Repository navigation
Dproano/logging - #2
jibbychohan wants to merge 16 commits into
Conversation
0fcc76d to
2be47d1
Compare
7cb22ae to
74f8652
Compare
| PT_TC_SPI_1.begin(); | ||
| PT_TC_SPI_3.begin(); | ||
|
|
||
| Flash::begin(); |
There was a problem hiding this comment.
move this down into the all_modules_ok section and check the return value - right now code silently continues if return is false!
| hqspi.Instance = QUADSPI; | ||
| hqspi.Init.ClockPrescaler = f_hclk / FREQ_MAX; | ||
| if (hqspi.Init.ClockPrescaler > 255) | ||
| hqspi.Init.ClockPrescaler = 255; |
There was a problem hiding this comment.
this logic has a bug!
If the division on line 330 has a remainder then the resulting clock frequency will exceed FREQ_MAX. You should increment the prescaler by one if the remainder is nonzero.
|
|
||
| flash_error_t write_to_cache(uint32_t col_addr, uint8_t *data, size_t len); | ||
|
|
||
| flash_error_t program(uint32_t addr); |
There was a problem hiding this comment.
Naming this parameter "addr" is misleading because I'm pretty sure it's really a row address. Need to confirm during testing because the datasheet isn't very specific.
| __HAL_RCC_GPIOF_CLK_ENABLE(); | ||
| __HAL_RCC_GPIOG_CLK_ENABLE(); | ||
|
|
||
| GPIO_InitTypeDef gpio_init{}; |
There was a problem hiding this comment.
this gpio init can definitely be done dynamically rather than being hardcoded. I believe Arduino already has pin map. Check out void pinmap_pinout(PinName pin, const PinMap *map).
| } | ||
|
|
||
| void init_qspi_gpio() { | ||
| __HAL_RCC_QSPI_CLK_ENABLE(); |
There was a problem hiding this comment.
HAL reference says (after enabling qspi clock in RCC):
Reset QuadSPI Peripheral with __HAL_RCC_QSPI_FORCE_RESET() and
__HAL_RCC_QSPI_RELEASE_RESET().
| bool init_qspi_peripheral() { | ||
| init_qspi_gpio(); | ||
|
|
||
| uint32_t f_hclk = HAL_RCC_GetHCLKFreq(); |
There was a problem hiding this comment.
Double-check that the quadspi kernel clock is being sourced from HCLK. There are four different clocks that can be muxed to quadspi.
In the HAL reference for RCC:
"
Once the device started from reset, the user application has to:
...
Configure the clock kernel source(s) for peripherals which clocks are not derived from the System clock
through :RCC_D1CCIPR,RCC_D2CCIP1R,RCC_D2CCIP2R and RCC_D3CCIPR registers
" (p. 1296)
see HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig (RCC_PeriphCLKInitTypeDef * PeriphClkInit)
| hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0; | ||
| hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE; | ||
| hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_8_CYCLE; | ||
| hqspi.Init.FlashSize = 23; |
There was a problem hiding this comment.
This should be set to 26 because our flash is 1Gb (2^27 bytes) and from the reference manual this should be set to FlashSize = (1 - log2(1GB)) = 26
74a004c to
bdab5f7
Compare
No description provided.