Tiva. Wait for peripheral ready after enabling its clock.

This was already done for some peripherals, but not for GPT, I2C, PWM and UART.
This commit is contained in:
marcoveeneman 2016-05-12 23:45:41 +02:00
parent 32e712aae1
commit 0e86736605
4 changed files with 134 additions and 6 deletions

View File

@ -462,6 +462,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_GPT0
if (&GPTD1 == gptp) {
SYSCTL->RCGCTIMER |= (1 << 0);
while (!(SYSCTL->PRTIMER & (1 << 0)))
;
nvicEnableVector(TIVA_GPT0A_NUMBER, TIVA_GPT_GPT0A_IRQ_PRIORITY);
}
#endif
@ -469,6 +473,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_GPT1
if (&GPTD2 == gptp) {
SYSCTL->RCGCTIMER |= (1 << 1);
while (!(SYSCTL->PRTIMER & (1 << 1)))
;
nvicEnableVector(TIVA_GPT1A_NUMBER, TIVA_GPT_GPT1A_IRQ_PRIORITY);
}
#endif
@ -476,6 +484,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_GPT2
if (&GPTD3 == gptp) {
SYSCTL->RCGCTIMER |= (1 << 2);
while (!(SYSCTL->PRTIMER & (1 << 2)))
;
nvicEnableVector(TIVA_GPT2A_NUMBER, TIVA_GPT_GPT2A_IRQ_PRIORITY);
}
#endif
@ -483,6 +495,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_GPT3
if (&GPTD4 == gptp) {
SYSCTL->RCGCTIMER |= (1 << 3);
while (!(SYSCTL->PRTIMER & (1 << 3)))
;
nvicEnableVector(TIVA_GPT3A_NUMBER, TIVA_GPT_GPT3A_IRQ_PRIORITY);
}
#endif
@ -490,6 +506,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_GPT4
if (&GPTD5 == gptp) {
SYSCTL->RCGCTIMER |= (1 << 4);
while (!(SYSCTL->PRTIMER & (1 << 4)))
;
nvicEnableVector(TIVA_GPT4A_NUMBER, TIVA_GPT_GPT4A_IRQ_PRIORITY);
}
#endif
@ -497,6 +517,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_GPT5
if (&GPTD6 == gptp) {
SYSCTL->RCGCTIMER |= (1 << 5);
while (!(SYSCTL->PRTIMER & (1 << 5)))
;
nvicEnableVector(TIVA_GPT5A_NUMBER, TIVA_GPT_GPT5A_IRQ_PRIORITY);
}
#endif
@ -504,6 +528,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_WGPT0
if (&GPTD7 == gptp) {
SYSCTL->RCGCWTIMER |= (1 << 0);
while (!(SYSCTL->PRWTIMER & (1 << 0)))
;
nvicEnableVector(TIVA_WGPT0A_NUMBER, TIVA_GPT_WGPT0A_IRQ_PRIORITY);
}
#endif
@ -511,6 +539,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_WGPT1
if (&GPTD8 == gptp) {
SYSCTL->RCGCWTIMER |= (1 << 1);
while (!(SYSCTL->PRWTIMER & (1 << 1)))
;
nvicEnableVector(TIVA_WGPT1A_NUMBER, TIVA_GPT_WGPT1A_IRQ_PRIORITY);
}
#endif
@ -518,6 +550,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_WGPT2
if (&GPTD9 == gptp) {
SYSCTL->RCGCWTIMER |= (1 << 2);
while (!(SYSCTL->PRWTIMER & (1 << 2)))
;
nvicEnableVector(TIVA_WGPT2A_NUMBER, TIVA_GPT_WGPT2A_IRQ_PRIORITY);
}
#endif
@ -525,6 +561,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_WGPT3
if (&GPTD10 == gptp) {
SYSCTL->RCGCWTIMER |= (1 << 3);
while (!(SYSCTL->PRWTIMER & (1 << 3)))
;
nvicEnableVector(TIVA_WGPT3A_NUMBER, TIVA_GPT_WGPT3A_IRQ_PRIORITY);
}
#endif
@ -532,6 +572,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_WGPT4
if (&GPTD11 == gptp) {
SYSCTL->RCGCWTIMER |= (1 << 4);
while (!(SYSCTL->PRWTIMER & (1 << 4)))
;
nvicEnableVector(TIVA_WGPT4A_NUMBER, TIVA_GPT_WGPT4A_IRQ_PRIORITY);
}
#endif
@ -539,6 +583,10 @@ void gpt_lld_start(GPTDriver *gptp)
#if TIVA_GPT_USE_WGPT5
if (&GPTD12 == gptp) {
SYSCTL->RCGCWTIMER |= (1 << 5);
while (!(SYSCTL->PRWTIMER & (1 << 5)))
;
nvicEnableVector(TIVA_WGPT5A_NUMBER, TIVA_GPT_WGPT5A_IRQ_PRIORITY);
}
#endif

View File

@ -504,6 +504,10 @@ void i2c_lld_start(I2CDriver *i2cp)
#if TIVA_I2C_USE_I2C0
if (&I2CD1 == i2cp) {
SYSCTL->RCGCI2C |= (1 << 0);
while (!(SYSCTL->PRI2C & (1 << 0)))
;
nvicEnableVector(TIVA_I2C0_NUMBER, TIVA_I2C_I2C0_IRQ_PRIORITY);
}
#endif /* TIVA_I2C_USE_I2C0 */
@ -511,6 +515,10 @@ void i2c_lld_start(I2CDriver *i2cp)
#if TIVA_I2C_USE_I2C1
if (&I2CD2 == i2cp) {
SYSCTL->RCGCI2C |= (1 << 1);
while (!(SYSCTL->PRI2C & (1 << 1)))
;
nvicEnableVector(TIVA_I2C1_NUMBER, TIVA_I2C_I2C1_IRQ_PRIORITY);
}
#endif /* TIVA_I2C_USE_I2C1 */
@ -518,6 +526,10 @@ void i2c_lld_start(I2CDriver *i2cp)
#if TIVA_I2C_USE_I2C2
if (&I2CD3 == i2cp) {
SYSCTL->RCGCI2C |= (1 << 2);
while (!(SYSCTL->PRI2C & (1 << 2)))
;
nvicEnableVector(TIVA_I2C2_NUMBER, TIVA_I2C_I2C2_IRQ_PRIORITY);
}
#endif /* TIVA_I2C_USE_I2C2 */
@ -525,6 +537,10 @@ void i2c_lld_start(I2CDriver *i2cp)
#if TIVA_I2C_USE_I2C3
if (&I2CD4 == i2cp) {
SYSCTL->RCGCI2C |= (1 << 3);
while (!(SYSCTL->PRI2C & (1 << 3)))
;
nvicEnableVector(TIVA_I2C3_NUMBER, TIVA_I2C_I2C3_IRQ_PRIORITY);
}
#endif /* TIVA_I2C_USE_I2C3 */
@ -532,6 +548,10 @@ void i2c_lld_start(I2CDriver *i2cp)
#if TIVA_I2C_USE_I2C4
if (&I2CD5 == i2cp) {
SYSCTL->RCGCI2C |= (1 << 4);
while (!(SYSCTL->PRI2C & (1 << 4)))
;
nvicEnableVector(TIVA_I2C4_NUMBER, TIVA_I2C_I2C4_IRQ_PRIORITY);
}
#endif /* TIVA_I2C_USE_I2C4 */
@ -539,6 +559,10 @@ void i2c_lld_start(I2CDriver *i2cp)
#if TIVA_I2C_USE_I2C5
if (&I2CD6 == i2cp) {
SYSCTL->RCGCI2C |= (1 << 5);
while (!(SYSCTL->PRI2C & (1 << 5)))
;
nvicEnableVector(TIVA_I2C5_NUMBER, TIVA_I2C_I2C5_IRQ_PRIORITY);
}
#endif /* TIVA_I2C_USE_I2C5 */
@ -546,6 +570,10 @@ void i2c_lld_start(I2CDriver *i2cp)
#if TIVA_I2C_USE_I2C6
if (&I2CD7 == i2cp) {
SYSCTL->RCGCI2C |= (1 << 6);
while (!(SYSCTL->PRI2C & (1 << 6)))
;
nvicEnableVector(TIVA_I2C6_NUMBER, TIVA_I2C_I2C6_IRQ_PRIORITY);
}
#endif /* TIVA_I2C_USE_I2C6 */
@ -553,6 +581,10 @@ void i2c_lld_start(I2CDriver *i2cp)
#if TIVA_I2C_USE_I2C7
if (&I2CD8 == i2cp) {
SYSCTL->RCGCI2C |= (1 << 7);
while (!(SYSCTL->PRI2C & (1 << 7)))
;
nvicEnableVector(TIVA_I2C7_NUMBER, TIVA_I2C_I2C7_IRQ_PRIORITY);
}
#endif /* TIVA_I2C_USE_I2C7 */
@ -560,6 +592,10 @@ void i2c_lld_start(I2CDriver *i2cp)
#if TIVA_I2C_USE_I2C8
if (&I2CD9 == i2cp) {
SYSCTL->RCGCI2C |= (1 << 8);
while (!(SYSCTL->PRI2C & (1 << 8)))
;
nvicEnableVector(TIVA_I2C8_NUMBER, TIVA_I2C_I2C8_IRQ_PRIORITY);
}
#endif /* TIVA_I2C_USE_I2C7 */
@ -567,6 +603,10 @@ void i2c_lld_start(I2CDriver *i2cp)
#if TIVA_I2C_USE_I2C9
if (&I2CD10 == i2cp) {
SYSCTL->RCGCI2C |= (1 << 9);
while (!(SYSCTL->PRI2C & (1 << 9)))
;
nvicEnableVector(TIVA_I2C9_NUMBER, TIVA_I2C_I2C9_IRQ_PRIORITY);
}
#endif /* TIVA_I2C_USE_I2C7 */

View File

@ -341,6 +341,10 @@ void pwm_lld_start(PWMDriver *pwmp)
#if TIVA_PWM_USE_PWM0
if (&PWMD1 == pwmp) {
SYSCTL->RCGCPWM |= (1 << 0);
while (!(SYSCTL->PRPWM & (1 << 0)))
;
nvicEnableVector(TIVA_PWM0FAULT_NUMBER,
TIVA_PWM_PWM0_FAULT_IRQ_PRIORITY);
nvicEnableVector(TIVA_PWM0GEN0_NUMBER, TIVA_PWM_PWM0_0_IRQ_PRIORITY);
@ -353,6 +357,10 @@ void pwm_lld_start(PWMDriver *pwmp)
#if TIVA_PWM_USE_PWM1
if (&PWMD2 == pwmp) {
SYSCTL->RCGCPWM |= (1 << 1);
while (!(SYSCTL->PRPWM & (1 << 1)))
;
nvicEnableVector(TIVA_PWM1FAULT_NUMBER,
TIVA_PWM_PWM1_FAULT_IRQ_PRIORITY);
nvicEnableVector(TIVA_PWM1GEN0_NUMBER, TIVA_PWM_PWM1_0_IRQ_PRIORITY);

View File

@ -508,48 +508,80 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config)
#if TIVA_SERIAL_USE_UART0
if (&SD1 == sdp) {
SYSCTL->RCGCUART |= (1 << 0);
while (!(SYSCTL->PRUART & (1 << 0)))
;
nvicEnableVector(TIVA_UART0_NUMBER, TIVA_SERIAL_UART0_PRIORITY);
}
#endif
#if TIVA_SERIAL_USE_UART1
if (&SD2 == sdp) {
SYSCTL->RCGCUART |= (1 << 1);
while (!(SYSCTL->PRUART & (1 << 1)))
;
nvicEnableVector(TIVA_UART1_NUMBER, TIVA_SERIAL_UART1_PRIORITY);
}
#endif
#if TIVA_SERIAL_USE_UART2
if (&SD3 == sdp) {
SYSCTL->RCGCUART |= (1 << 2); /* enable UART2 module */
SYSCTL->RCGCUART |= (1 << 2);
while (!(SYSCTL->PRUART & (1 << 2)))
;
nvicEnableVector(TIVA_UART2_NUMBER, TIVA_SERIAL_UART2_PRIORITY);
}
#endif
#if TIVA_SERIAL_USE_UART3
if (&SD4 == sdp) {
SYSCTL->RCGCUART |= (1 << 3); /* enable UART3 module */
SYSCTL->RCGCUART |= (1 << 3);
while (!(SYSCTL->PRUART & (1 << 3)))
;
nvicEnableVector(TIVA_UART3_NUMBER, TIVA_SERIAL_UART3_PRIORITY);
}
#endif
#if TIVA_SERIAL_USE_UART4
if (&SD5 == sdp) {
SYSCTL->RCGCUART |= (1 << 4); /* enable UART4 module */
SYSCTL->RCGCUART |= (1 << 4);
while (!(SYSCTL->PRUART & (1 << 4)))
;
nvicEnableVector(TIVA_UART4_NUMBER, TIVA_SERIAL_UART4_PRIORITY);
}
#endif
#if TIVA_SERIAL_USE_UART5
if (&SD6 == sdp) {
SYSCTL->RCGCUART |= (1 << 5); /* enable UART5 module */
SYSCTL->RCGCUART |= (1 << 5);
while (!(SYSCTL->PRUART & (1 << 5)))
;
nvicEnableVector(TIVA_UART5_NUMBER, TIVA_SERIAL_UART5_PRIORITY);
}
#endif
#if TIVA_SERIAL_USE_UART6
if (&SD7 == sdp) {
SYSCTL->RCGCUART |= (1 << 6); /* enable UART6 module */
SYSCTL->RCGCUART |= (1 << 6);
while (!(SYSCTL->PRUART & (1 << 6)))
;
nvicEnableVector(TIVA_UART6_NUMBER, TIVA_SERIAL_UART6_PRIORITY);
}
#endif
#if TIVA_SERIAL_USE_UART7
if (&SD8 == sdp) {
SYSCTL->RCGCUART |= (1 << 7); /* enable UART7 module */
SYSCTL->RCGCUART |= (1 << 7);
while (!(SYSCTL->PRUART & (1 << 7)))
;
nvicEnableVector(TIVA_UART7_NUMBER, TIVA_SERIAL_UART7_PRIORITY);
}
#endif