[9XR-PRO] i2c was not initialized

This commit is contained in:
Bertrand Songis
2014-01-09 11:42:13 +01:00
parent b6aca8c0f5
commit b94da82e17
2 changed files with 27 additions and 29 deletions
+27 -3
View File
@@ -531,6 +531,32 @@ void configure_pins( uint32_t pins, uint16_t config )
void opentxBootloader();
// Set up for volume control (TWI0)
// Need PA3 and PA4 set to peripheral A
void i2cInit()
{
register Pio *pioptr ;
register uint32_t timing ;
PMC->PMC_PCER0 |= 0x00080000L ; // Enable peripheral clock to TWI0
/* Configure PIO */
pioptr = PIOA ;
pioptr->PIO_ABCDSR[0] &= ~0x00000018 ; // Peripheral A
pioptr->PIO_ABCDSR[1] &= ~0x00000018 ; // Peripheral A
pioptr->PIO_PDR = 0x00000018 ; // Assign to peripheral
timing = Master_frequency * 5 / 1000000 ; // 5uS high and low
timing += 15 - 4 ;
timing /= 16 ;
timing |= timing << 8 ;
TWI0->TWI_CWGR = 0x00040000 | timing ; // TWI clock set
TWI0->TWI_CR = TWI_CR_MSEN | TWI_CR_SVDIS ; // Master mode enable
TWI0->TWI_MMR = 0x002F0000 ; // Device 5E (>>1) and master is writing
NVIC_EnableIRQ(TWI0_IRQn) ;
}
void boardInit()
{
register Pio *pioptr ;
@@ -614,9 +640,7 @@ void boardInit()
audioInit();
#if defined(COPROCESSOR)
coprocInit();
#endif
i2cInit();
eepromInit();
-26
View File
@@ -141,32 +141,6 @@ void coprocWriteData(uint8_t *data, uint32_t size)
__enable_irq();
}
// Set up for volume control (TWI0)
// Need PA3 and PA4 set to peripheral A
void coprocInit()
{
register Pio *pioptr ;
register uint32_t timing ;
PMC->PMC_PCER0 |= 0x00080000L ; // Enable peripheral clock to TWI0
/* Configure PIO */
pioptr = PIOA ;
pioptr->PIO_ABCDSR[0] &= ~0x00000018 ; // Peripheral A
pioptr->PIO_ABCDSR[1] &= ~0x00000018 ; // Peripheral A
pioptr->PIO_PDR = 0x00000018 ; // Assign to peripheral
timing = Master_frequency * 5 / 1000000 ; // 5uS high and low
timing += 15 - 4 ;
timing /= 16 ;
timing |= timing << 8 ;
TWI0->TWI_CWGR = 0x00040000 | timing ; // TWI clock set
TWI0->TWI_CR = TWI_CR_MSEN | TWI_CR_SVDIS ; // Master mode enable
TWI0->TWI_MMR = 0x002F0000 ; // Device 5E (>>1) and master is writing
NVIC_EnableIRQ(TWI0_IRQn) ;
}
#if !defined(SIMU)
extern "C" void TWI0_IRQHandler()
{