-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register readback on most modules. Still need to convert the other on…
…es (#396) * Added an initial working implementation of the register readback and applied it to the LLCAN registers. Also fixed an init bug in CAN. * Locally disable pylint import error * Reverted change to CAN-obj->FA1R setting * Fixed misra compliance * Changed hash function name * Fixed CAN filter setting * Added voltage health test * Converted ADC to register functions * Converted clock to use register setters * Added check to see if fault status is zero after running test * Converted DAC to use register setters * Converted fan to use register setters * Converted gmlan bitbanging to use register setters * Changed over interrupt driver to use register setters. Also moved some includes and definition places for critical sections * Fixed build * Converted LLGPIO to use register setters * Converted pwm to use register setters * Fixed cold boot * Fixed health fault check in automated tests * Added comment for the future (issue #367) * Converted RTC driver to use register setters * Converted SPI to use register setters * Converted timer driver to use register setters * Fixed register fault on white pandas and disabled showing of fault for release * Bump version
- Loading branch information
1 parent
6bbae7b
commit 893e486
Showing
25 changed files
with
306 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v1.6.8 | ||
v1.6.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// ********************* Critical section helpers ********************* | ||
volatile bool interrupts_enabled = false; | ||
|
||
void enable_interrupts(void) { | ||
interrupts_enabled = true; | ||
__enable_irq(); | ||
} | ||
|
||
void disable_interrupts(void) { | ||
interrupts_enabled = false; | ||
__disable_irq(); | ||
} | ||
|
||
uint8_t global_critical_depth = 0U; | ||
#define ENTER_CRITICAL() \ | ||
__disable_irq(); \ | ||
global_critical_depth += 1U; | ||
|
||
#define EXIT_CRITICAL() \ | ||
global_critical_depth -= 1U; \ | ||
if ((global_critical_depth == 0U) && interrupts_enabled) { \ | ||
__enable_irq(); \ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
void clock_init(void) { | ||
// enable external oscillator | ||
RCC->CR |= RCC_CR_HSEON; | ||
register_set_bits(&(RCC->CR), RCC_CR_HSEON); | ||
while ((RCC->CR & RCC_CR_HSERDY) == 0); | ||
|
||
// divide things | ||
RCC->CFGR = RCC_CFGR_HPRE_DIV1 | RCC_CFGR_PPRE2_DIV2 | RCC_CFGR_PPRE1_DIV4; | ||
register_set(&(RCC->CFGR), RCC_CFGR_HPRE_DIV1 | RCC_CFGR_PPRE2_DIV2 | RCC_CFGR_PPRE1_DIV4, 0xFF7FFCF3U); | ||
|
||
// 16mhz crystal | ||
RCC->PLLCFGR = RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLM_3 | | ||
RCC_PLLCFGR_PLLN_6 | RCC_PLLCFGR_PLLN_5 | RCC_PLLCFGR_PLLSRC_HSE; | ||
register_set(&(RCC->PLLCFGR), RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLN_6 | RCC_PLLCFGR_PLLN_5 | RCC_PLLCFGR_PLLSRC_HSE, 0x7F437FFFU); | ||
|
||
// start PLL | ||
RCC->CR |= RCC_CR_PLLON; | ||
register_set_bits(&(RCC->CR), RCC_CR_PLLON); | ||
while ((RCC->CR & RCC_CR_PLLRDY) == 0); | ||
|
||
// Configure Flash prefetch, Instruction cache, Data cache and wait state | ||
// *** without this, it breaks *** | ||
FLASH->ACR = FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS; | ||
register_set(&(FLASH->ACR), FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS, 0x1F0FU); | ||
|
||
// switch to PLL | ||
RCC->CFGR |= RCC_CFGR_SW_PLL; | ||
register_set_bits(&(RCC->CFGR), RCC_CFGR_SW_PLL); | ||
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); | ||
|
||
// *** running on PLL *** | ||
} | ||
|
||
void watchdog_init(void) { | ||
// setup watchdog | ||
IWDG->KR = 0x5555; | ||
IWDG->PR = 0; // divider /4 | ||
IWDG->KR = 0x5555U; | ||
register_set(&(IWDG->PR), 0x0U, 0x7U); // divider/4 | ||
|
||
// 0 = 0.125 ms, let's have a 50ms watchdog | ||
IWDG->RLR = 400 - 1; | ||
IWDG->KR = 0xCCCC; | ||
register_set(&(IWDG->RLR), (400U-1U), 0xFFFU); | ||
IWDG->KR = 0xCCCCU; | ||
} | ||
|
||
void watchdog_feed(void) { | ||
IWDG->KR = 0xAAAA; | ||
IWDG->KR = 0xAAAAU; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.