void A110x2500SpiWrite(unsigned char address, const unsigned char *buffer, unsigned char count) { digitalWrite(RF_SPI_CSN,LOW); // Look for CHIP_RDYn from radio. pinMode(RF_SPI_MISO, INPUT); while (digitalRead(RF_SPI_MISO)); MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION); SPI_enableModule(EUSCI_B0_BASE); // Write the address/command byte. SPI.transfer(address); // Write dummy byte(s) and read response(s). for (unsigned char i = 0; i < count; i++) { SPI.transfer(buffer[i]); } // Note: It is assumed that the Energia SPI driver waits until the USCIB0 // peripheral is done being busy before returning to the caller. digitalWrite(RF_SPI_CSN,HIGH); SPI_disableModule(EUSCI_B0_BASE); }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ int spi_Open(void) { GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6, GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5, GPIO_PRIMARY_MODULE_FUNCTION); /* Configuring SPI in 3wire master mode */ SPI_initMaster(EUSCI_B1_MODULE, &LIGHTspiConfig); /* Enable SPI module */ SPI_enableModule(EUSCI_B1_MODULE); return 0;//NONOS_RET_OK; }
////------------------------------------------------------------------------------ Fd_t spi_Open(void) { /* Selecting P9.5 P9.6 and P9.7 in SPI mode */ GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6, GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5, GPIO_PRIMARY_MODULE_FUNCTION); /* CS setup. */ GPIO_setAsOutputPin(GPIO_PORT_P4, GPIO_PIN6); GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN6); /* Configuring SPI in 3wire master mode */ SPI_initMaster(EUSCI_B1_MODULE, &SDspiConfig); /* Enable SPI module */ SPI_enableModule(EUSCI_B1_MODULE); return 0;//NONOS_RET_OK; }
void HAL_LCD_SpiInit(void) { eUSCI_SPI_MasterConfig config = { EUSCI_B_SPI_CLOCKSOURCE_SMCLK, LCD_SYSTEM_CLOCK_SPEED, LCD_SPI_CLOCK_SPEED, EUSCI_B_SPI_MSB_FIRST, EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT, EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW, EUSCI_B_SPI_3PIN }; SPI_initMaster(LCD_EUSCI_BASE, &config); SPI_enableModule(LCD_EUSCI_BASE); GPIO_setOutputLowOnPin(LCD_CS_PORT, LCD_CS_PIN); GPIO_setOutputHighOnPin(LCD_DC_PORT, LCD_DC_PIN); }