// note must be called after you have the mutex - after // radio max clock freq = 10mhz // MSP430 max fre clkI cycles - we might be violating this // SD card -fast frequency ~= 2 MHz // sound chip - 2s to be 400kHz at first, then bump up speed void SPIConfigure(uint32 ulBase, uint8 wordSize, uint8 mode, uint32 frequency) { if ((wordSize != SPIWordSize) || (mode != SPIMode) || (frequency != SPIFrequency)) { // cache word size value SPIWordSize = wordSize; SPIMode = mode; SPIFrequency = frequency; MAP_SSIDisable(ulBase); // Configure the SSI0 port for master mode with all the configuration settings MAP_SSIConfigSetExpClk(ulBase, SYSCTL_CLOCK_FREQ, SPIMode, SSI_MODE_MASTER, SPIFrequency, SPIWordSize); // Enable the SSI port. MAP_SSIEnable(ulBase); } }
u32 platform_spi_setup( unsigned id, int mode, u32 clock, unsigned cpol, unsigned cpha, unsigned databits ) { unsigned protocol; if( cpol == 0 ) protocol = cpha ? SSI_FRF_MOTO_MODE_1 : SSI_FRF_MOTO_MODE_0; else protocol = cpha ? SSI_FRF_MOTO_MODE_3 : SSI_FRF_MOTO_MODE_2; mode = mode == PLATFORM_SPI_MASTER ? SSI_MODE_MASTER : SSI_MODE_SLAVE; MAP_SSIDisable( spi_base[ id ] ); MAP_GPIOPinTypeSSI( spi_gpio_base[ id ], spi_gpio_pins[ id ] ); // FIXME: not sure this is always "right" // MAP_GPIOPadConfigSet(spi_gpio_base[ id ], spi_gpio_clk_pin[ id ], GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU); MAP_SSIConfigSetExpClk( spi_base[ id ], MAP_SysCtlClockGet(), protocol, mode, clock, databits ); MAP_SSIEnable( spi_base[ id ] ); return clock; }
//-------------------------------- void ssi_peripheral::Terminate() { switch (m_nDevice) { case ssi_peripheral::SSI0: g_pTheSSI0 = 0; break; case ssi_peripheral::SSI1: g_pTheSSI1 = 0; break; case ssi_peripheral::SSI2: g_pTheSSI2 = 0; break; case ssi_peripheral::SSI3: g_pTheSSI3 = 0; break; default: break; } SSIIntDisable(m_rSpecification.m_nSSIBase, SSI_TXFF); /* SSI_TXFF | SSI_RXFF | SSI_RXTO | SSI_RXOR */ MAP_IntDisable(m_rSpecification.m_nInterrupt); MAP_SSIDisable(m_rSpecification.m_nSSIBase); }