//***************************************************************************** // //! \brief Initialize TC77 //! //! \param ulClock specifies the SPI Clock Rate //! //! This function is to initialize the MCU as master and specified SPI port.Set //! TC77_PIN_SPI_CS as CS, TC77_PIN_SPI_CLK as CLK, TC77_PIN_SPI_MISO ->MISO and //! TC77_PIN_SPI_MOSI->MOSI,most of all it check the first conversion is finished //! or not in order to execute the following operation. //! //! \return None. // //***************************************************************************** void TC77Init(unsigned long ulSpiClock) { short sReadValue = 0; // // The max clock rate of TC77 is 7M Hz acoording to Datasheet, Otherwise // it will generate bigger error // xASSERT((ulSpiClock > 0) && (ulSpiClock < 7000000)); // // Enable the GPIOx port which is connected with tc77 // xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(TC77_PIN_SPI_MISO)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(TC77_PIN_SPI_MOSI)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(TC77_PIN_SPI_CLK)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(TC77_PIN_SPI_CS)); // // Enable the SPIx which is connected with tc77 // xSysCtlPeripheralEnable2(TC77_PIN_SPI_PORT); // // Set TC77_PIN_SPI_CS as a chip select pin and set it as OUT_MODE // xGPIOSPinDirModeSet(TC77_PIN_SPI_CS, xGPIO_DIR_MODE_OUT); // // Set TC77_PIN_SPI_CLK as SPIx.CLK // xSPinTypeSPI(TC77_SPI_CLK, TC77_PIN_SPI_CLK); // // Set TC77_PIN_SPI_MISO as SPIx.MISO // xSPinTypeSPI(TC77_SPI_MISO, TC77_PIN_SPI_MISO); // // Configure MCU as a master device , 16 bits data width ,MSB first,Mode_0 // xSPIConfigSet(TC77_PIN_SPI_PORT, ulSpiClock, xSPI_MOTO_FORMAT_MODE_0 | xSPI_DATA_WIDTH16 | xSPI_MODE_MASTER | xSPI_MSB_FIRST); // // Disable TC77 when Power up // xGPIOSPinWrite(TC77_PIN_SPI_CS, 1); // // Wait for the first conversion completed // while(!(0x0004 & sReadValue)) { sReadValue = TC77TemperRead(); } }
//***************************************************************************** // //! \brief Initialize AT45DB161 and SPI //! //! \param ulSpiClock specifies the SPI Clock Rate //! //! This function initialize the mcu SPI as master and specified SPI port. //! After SPI and port was configured, the mcu send a AT45DB161_CMD_SRRD command //! to get the page size of AT45DB161 to get prepareed for the followed read and //! write operations. //! //! \return None. // //***************************************************************************** void AT45DB161_Init(unsigned long ulSpiClock) { unsigned char tmp; xASSERT((ulSpiClock > 0) && (ulSpiClock < AT45DB161_MAX_CLK)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(AT45DB161_SCK)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(AT45DB161_CS_PIN)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(AT45DB161_MISO)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(AT45DB161_MOSI)); xSysCtlPeripheralEnable2(AT45DB161_SPI_PORT); xSysCtlPeripheralEnable(SYSCTL_PERIPH_AFIO); xGPIOSPinDirModeSet(AT45DB161_CS_PIN, xGPIO_DIR_MODE_OUT); #if (AT45DB161_WRITE_PROTECT < 1) xGPIOSPinDirModeSet(FLASH_PIN_WRITE_PROTECT, xGPIO_DIR_MODE_OUT); xGPIOSPinWrite(FLASH_PIN_WRITE_PROTECT, 0); #endif // // PD1 as SPI2.CLK // xSPinTypeSPI(SPI_CLK, AT45DB161_SCK); // // PD2 as SPI2.MISO // MISO20 => SPI0MISO // xSPinTypeSPI(SPI_MISO, AT45DB161_MISO); // // PD3 as SPI2.MOSI // MOSI20 => SPI0MISO // xSPinTypeSPI(SPI_MOSI, AT45DB161_MOSI); //xSysCtlPeripheralEnable(SYSCTL_PERIPH_AFIO); // //! Set SPI mode. // xSPIConfigSet(AT45DB161_SPI_PORT, ulSpiClock, SPI_MODE_MASTER | SPI_MSB_FIRST | SPI_2LINE_FULL | SPI_DATA_WIDTH8 | SPI_FORMAT_MODE_4); SPISSModeConfig(AT45DB161_SPI_PORT, SPI_CR1_SSM); SPISSIConfig(AT45DB161_SPI_PORT, SPI_CR1_SSI); SPIEnble(AT45DB161_SPI_PORT); AT45DB161_CS = 1; xSPISingleDataReadWrite(AT45DB161_SPI_PORT, 0xFF); xSysCtlDelay(100000); AT45DB161_CS = 0; // //! Read AT45DB161 state register to get the page size. // xSPISingleDataReadWrite(AT45DB161_SPI_PORT, AT45DB161_CMD_SRRD); tmp = xSPISingleDataReadWrite(AT45DB161_SPI_PORT, 0xFF); if(tmp & AT45DB161_PGSZ) AT45DB161_PageSize = 512; AT45DB161_CS = 1; }
// // Enable I2C, GPIO clock // Set pins to I2C funciton // void pinSet() { // // Enable GPIO Clock // xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(PA8)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(PA9)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(PB13)); xSPinTypeI2C(I2C0SDA, PA8); xSPinTypeI2C(I2C0SCK, PA9); }
//***************************************************************************** // //! \brief Initializes the PTC08 device. //! //! Initializes the PTC08 device,it will set the baud rate 115200,image size //! 320*240,ziprate 36 and non-save power. //! //! \return None. // //***************************************************************************** xtBoolean PTC08Init(void) { xSysCtlPeripheralEnable2(PTC08_UART); xSysCtlPeripheralEnable2(xGPIOSPinToPeripheralId(PTC08_PIN_UART_RX)); xSysCtlPeripheralEnable2(xGPIOSPinToPeripheralId(PTC08_PIN_UART_TX)); xSysCtlPeripheralClockSourceSet(xSYSCTL_UART1_MAIN, 1); xSPinTypeUART(PTC08_UART_RX, PTC08_PIN_UART_RX); xSPinTypeUART(PTC08_UART_TX, PTC08_PIN_UART_TX); xUARTConfigSet(PTC08_UART, 38400, (xUART_CONFIG_WLEN_8 | xUART_CONFIG_STOP_1 | xUART_CONFIG_PAR_NONE)); xUARTEnable(PTC08_UART, (xUART_BLOCK_UART | xUART_BLOCK_TX | xUART_BLOCK_RX)); // // Must wait for 2.5s before the camera can received Command // xSysCtlDelay(25000000); if(!PTC08PhotoReset()) { return xfalse; } if(!PTC08PhotoSizeSet(PTC08_SIZE_320_240)) { return xfalse; } if(!PTC08ZipRateSet(0x36)) { return xfalse; } xSysCtlDelay(10); if(!PTC08SavePowerSet(PTC08_SAVE_POWER_DIS)) { return xfalse; } if(!PTC08BaudRateSet(PTC08_BAUDRATE_115200)) { return xfalse; } xUARTConfigSet(PTC08_UART, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); return xtrue; }
void LCDShield(void) { int key; xSysCtlClockSet(12000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_12MHZ); xSysCtlDelay(1000); xSysCtlPeripheralEnable(xSYSCTL_PERIPH_UART0); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(sD13)); xSysCtlPeripheralClockSourceSet(xSYSCTL_UART0_MAIN, 1); LCDShieldInit(); // // Enable Peripheral SPI0 // xSysCtlPeripheralEnable(SYSCTL_PERIPH_ADC); xSPinTypeADC(ADC0, sA0); // // ADC Channel0 convert once, Software tirgger. // xADCConfigure(xADC0_BASE, xADC_MODE_SCAN_CONTINUOUS, ADC_TRIGGER_PROCESSOR); // // Enable the channel0 // xADCStepConfigure(xADC0_BASE, 0, xADC_CTL_CH0); // // Enable the adc // xADCEnable(xADC0_BASE); // // start ADC convert // xADCProcessorTrigger( xADC0_BASE ); LCDShieldLocationSet(0, 0); LCDShieldDisplayString("Hello Nuvoton!"); LCDShieldLocationSet(0, 1); LCDShieldDisplayString("Hello CooCox! "); xSysCtlDelay(1000000); while(1) { key = LCDShieldButtonGet(); if(key != -1) { LCDShieldDisplayClear(); LCDShieldLocationSet(0, 0); LCDShieldDisplayString("The key is: "); LCDShieldLocationSet(0, 1); LCDShieldDisplayString(&cKey[key][0]); } } }
void DeltaAngleGet() { tLPR5150ALData g_XYAxisCurrentVoltage; tLPR5150ALData g_XYAxisNullVoltage; tLPR5150ALData g_XYAxisAngle; tLPR5150ALData g_XYAxisRate; xSysCtlClockSet(12000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_12MHZ); xSysCtlDelay(1000); xSysCtlPeripheralEnable(xSYSCTL_PERIPH_UART0); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(sD13)); xSysCtlPeripheralClockSourceSet(xSYSCTL_UART0_MAIN, 1); sPinTypeUART(sUART_DBG_BASE); xUARTConfigSet(sUART_DBG_BASE, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); xUARTEnable(sUART_DBG_BASE, (UART_BLOCK_UART | UART_BLOCK_RX)); //automatically added by CoIDE //ADConvert(); xSysCtlClockSet(12000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_12MHZ); LPR5150ALInit(); while(1) { g_XYAxisAngle = LPR5150ALXYAxisAngleGet(); printf("The roll angle is: %f ", g_XYAxisAngle.fXAxisData); printf("The pitch angle is: %f \r\n", g_XYAxisAngle.fYAxisData); //DelayMS(500); } }
//***************************************************************************** // //! \brief Peripheral Initialization. //! //! \param None. //! //! This function is to Initialize joystick, LED, USART1, CH376, USB flash disk and VS1003. //! //! \return None. // //***************************************************************************** void PeriphInit() { unsigned char s; JoystickInit(); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(LED_PIN)); xGPIOSPinDirModeSet(LED_PIN, xGPIO_DIR_MODE_OUT); xGPIOSPinWrite( LED_PIN, 0 ); mInitSTDIO( ); s = mInitCH376Host( ); mStopIfError( s ); while ( CH376DiskConnect( ) != USB_INT_SUCCESS ) { xSysCtlDelay( 1000000 ); printf("Waiting for USB flash disk to plug in...\n\r"); } xSysCtlDelay( 2000000 ); for ( s = 0; s < 10; s ++ ) { xSysCtlDelay( 500000 ); if ( CH376DiskMount( ) == USB_INT_SUCCESS ) break; } VS10xxInit(); }
//***************************************************************************** // //! \brief MCU communication port initialize //! //! \param None //! //! \return None. // //***************************************************************************** void CH376PortInit( void ) { #ifdef CH376_INT_WIRE xSysCtlPeripheralEnable2(CH376_INT_PORT); xGPIOSPinDirModeSet(CH376_INT_PIN, xGPIO_DIR_MODE_IN); //pass xGPIOSPinWrite(CH376_INT_PIN, 1); #endif #ifdef CH376_USE_HARDWARE_SPI xSysCtlPeripheralEnable2(CH376_SPI_CS_PORT); xGPIOSPinDirModeSet(CH376_SPI_CS_PIN, xGPIO_DIR_MODE_OUT); xSysCtlPeripheralEnable(SYSCTL_PERIPH_AFIO); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_SCK)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_MOSI)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_MISO)); xSysCtlPeripheralEnable2(CH376_SPI_PORT); xSPinTypeSPI(CH376SPI_CLK, CH376_SCK); xSPinTypeSPI(CH376SPI_MISO, CH376_MISO); xSPinTypeSPI(CH376SPI_MOSI, CH376_MOSI); xSPIConfigSet(CH376_SPI_PORT, CH376_CLK_FREQ, SPI_MODE_MASTER | xSPI_MOTO_FORMAT_MODE_3 | xSPI_MODE_MASTER | xSPI_MSB_FIRST | xSPI_DATA_WIDTH8); // SPISSModeConfig(CH376_SPI_PORT, SPI_CR1_SSM); // SPISSIConfig(CH376_SPI_PORT, SPI_CR1_SSI); xSPISSSet( CH376_SPI_PORT, xSPI_SS_SOFTWARE, xSPI_SS0 ); SPIEnble(CH376_SPI_PORT); CH376_SPI_CS_SET; #endif //End of CH376_USE_HARDWARE_SPI define #ifdef CH376_USE_SOFTWARE_SPI xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_SCK_PIN)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_MISO_PIN)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_MOSI_PIN)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_SPI_CS_PIN)); xGPIOSPinDirModeSet(CH376_SPI_CS_PIN, xGPIO_DIR_MODE_OUT); xGPIOSPinDirModeSet(CH376_SCK_PIN, xGPIO_DIR_MODE_OUT); xGPIOSPinDirModeSet(CH376_MOSI_PIN, xGPIO_DIR_MODE_OUT); xGPIOSPinDirModeSet(CH376_MISO_PIN, xGPIO_DIR_MODE_IN); CH376_SPI_CS_SET; #endif //End of CH376_USE_SOFTWARE_SPI define #ifdef CH376_USE_PARALLEL xSysCtlPeripheralEnable2(CH376_WR_PORT); xSysCtlPeripheralEnable2(CH376_RD_PORT); xSysCtlPeripheralEnable2(CH376_A0_PORT); xSysCtlPeripheralEnable2(CH376_PCS_PORT); xSysCtlPeripheralEnable2(CH376_DATA_PORT); xGPIOSPinDirModeSet(CH376_WR_PIN, xGPIO_DIR_MODE_OUT); xGPIOSPinDirModeSet(CH376_RD_PIN, xGPIO_DIR_MODE_OUT); xGPIOSPinDirModeSet(CH376_A0_PIN, xGPIO_DIR_MODE_OUT); xGPIOSPinDirModeSet(CH376_PCS_PIN, xGPIO_DIR_MODE_OUT); xGPIODirModeSet( CH376_DATA_PORT, 0xFF, xGPIO_DIR_MODE_IN ); CH376_PCS_SET; CH376_WR_SET; CH376_RD_SET; CH376_A0_CLR; #endif //End of CH376_USE_PARALLEL define }
//***************************************************************************** // //! \brief Init the HD44780 LCD Device. //! //! \param None. //! //! This function is used to Init the HD44780 Device. It must be call before //! any other LCD function use. //! //! It Open the pins's GPIO peripheral port, and config the pins type to GPIO //! output. Then config the LCD into the default state, clear the LCD and //! Open the display. Default A Blink cursor is set on. The LCD cursor move //! direction is config as increment default. //! //! The HD44780 Initial state can be determined by the \ref HD44780_Config. //! - Pins that used is determined by \ref HD44780_Config_Pins. //! - The inteface data length is determined by \ref HD44780_INTERFACE_DATA_LEN. //! - The LCD display line is determined by \ref HD44780_DISPLAY_LINE. //! - The LCD character font is determined by \ref HD44780_CHARACTER_FONT. //! . //! //! \return None. // //***************************************************************************** void HD44780Init(void) { ucDisplayFunction = (HD44780_INTERFACE_DATA_LEN | HD44780_FUNCTION_SET_N_2 | HD44780_CHARACTER_FONT); ucRsPin = 1; ucRwPin = 255; ucEnablePin = 2; ucDataPin[0] = 6; ucDataPin[1] = 5; ucDataPin[2] = 4; ucDataPin[3] = 3; _SPIbuff = 0; xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(HD44780_PIN_CS)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(HD44780_PIN_CLK)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(HD44780_PIN_MOSI)); #if HD44780_SPI_MODE == SPIMODE_HARDWARE // // Enable Peripheral SPI1 // xSysCtlPeripheralEnable2(HD44780_SPI); SysCtlPeripheralEnable(SYSCTL_PERIPH_AFIO); // // Configure Some GPIO pins as SPI Mode SPI MISO is no use in LCD4884 // xSPinTypeSPI(HD44780_CLK,HD44780_PIN_CLK); xSPinTypeSPI(HD44780_MOSI,HD44780_PIN_MOSI); xGPIOSPinTypeGPIOOutput(HD44780_PIN_CS); // // Configure SPI SPI1,ulRate // xSPIConfigSet((HD44780_SPI), HD44780_SPI_BAUDRATE, SPI_FORMAT_MODE_3 | SPI_DATA_WIDTH8 | SPI_MSB_FIRST | SPI_MODE_MASTER); // //! \note Enanble SPI SS,test on M0516LBN.other mcu there may need modify. // xSPISSSet((HD44780_SPI), xSPI_SS_SOFTWARE, xSPI_SS0); xSPIEnable(HD44780_SPI); #else // // Set Pins Type to GPIO Output // xGPIOSPinTypeGPIOOutput(HD44780_PIN_CS); xGPIOSPinTypeGPIOOutput(HD44780_PIN_CLK); xGPIOSPinTypeGPIOOutput(HD44780_PIN_MOSI); #endif // // Output default value : E disable // // // Set Entry Mode: Interface Data Length, Character Font, Display Line // while(HD44780Busy()); HD44780WriteCmd(HD44780_CMD_FUNCTION_SET(HD44780_INTERFACE_DATA_LEN | HD44780_FUNCTION_SET_N_2 | HD44780_CHARACTER_FONT)); // // Display on & Cursor Blink // while(HD44780Busy()); HD44780WriteCmd(HD44780_CMD_DISPLAY_CTRL(HD44780_DISPLAY_CTRL_D | 0 | HD44780_DISPLAY_CTRL_B)); // // Clear LCD // while(HD44780Busy()); HD44780WriteCmd(HD44780_CMD_CLS); // // Cursor Move Mode: Increment // while(HD44780Busy()); HD44780WriteCmd(HD44780_CMD_ENTRY_MODE_SET(HD44780_ENTRY_MODE_SET_ID_INC | 0)); }
//***************************************************************************** // //! \brief Init the ST7735 LCD Device. //! //! \param None. //! //! This function is used to Init the ST7735 Device. It must be call before //! any other LCD function use. //! //! It Open the pins's GPIO peripheral port, and config the pins type to GPIO //! output. Then config the LCD into the default state, clear the LCD and //! Open the display. Default A Blink cursor is set on. The LCD cursor move //! direction is config as increment default. //! //! The ST7735 Initial state can be determined by the \ref ST7735_Config. //! - Pins that used is determined by \ref ST7735_Config_Pins. //! - The LCD display line is determined by \ref ST7735_DISPLAY_LINE. //! - The LCD character font is determined by \ref ST7735_CHARACTER_FONT. //! . //! //! \return None. // //***************************************************************************** void ST7735Init(void) { unsigned long ulCount; // // Enable GPIO Port that used // xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_D7)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_D6)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_D5)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_D4)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_D3)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_D2)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_D1)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_D0)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_RD)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_WR)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_CS)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_RS)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_RST)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(ST7735_PIN_BACKLIGHT)); // // Set Pins Type to GPIO Output // xGPIOSPinTypeGPIOOutput(ST7735_PIN_D7); xGPIOSPinTypeGPIOOutput(ST7735_PIN_D6); xGPIOSPinTypeGPIOOutput(ST7735_PIN_D5); xGPIOSPinTypeGPIOOutput(ST7735_PIN_D4); xGPIOSPinTypeGPIOOutput(ST7735_PIN_D3); xGPIOSPinTypeGPIOOutput(ST7735_PIN_D2); xGPIOSPinTypeGPIOOutput(ST7735_PIN_D1); xGPIOSPinTypeGPIOOutput(ST7735_PIN_D0); xGPIOSPinTypeGPIOOutput(ST7735_PIN_RD); xGPIOSPinTypeGPIOOutput(ST7735_PIN_WR); xGPIOSPinTypeGPIOOutput(ST7735_PIN_CS); xGPIOSPinTypeGPIOOutput(ST7735_PIN_RS); xGPIOSPinTypeGPIOOutput(ST7735_PIN_RST); xGPIOSPinTypeGPIOOutput(ST7735_PIN_BACKLIGHT); // // Turn on the backlight. // xGPIOSPinWrite(ST7735_PIN_BACKLIGHT, ST7735_BACKLIGHT_ON); xGPIOSPinWrite(ST7735_PIN_RST, ST7735_RST_ENABLE); xSysCtlDelay(100); xGPIOSPinWrite(ST7735_PIN_RST, ST7735_RST_DISABLE); xSysCtlDelay(100); ST7735WriteCmd(ST7735_SLPOUT_REG); //sleep out and booter on xSysCtlDelay(5000); ST7735WriteCmd(ST7735_FRMCTR1_REG); // ST7735WriteData(0x12C); ST7735WriteData(0x2D00); ST7735WriteCmd(ST7735_FRMCTR2_REG); // ST7735WriteData(0x12C); ST7735WriteData(0x2D00); ST7735WriteCmd(ST7735_FRMCTR3_REG); // ST7735WriteData(0x12C); ST7735WriteData(0x2D01); ST7735WriteData(0x2C2D); ST7735WriteCmd(ST7735_INVCTR_REG); // ST7735WriteData(0x07); //============ power control setting ========================== ST7735WriteCmd(ST7735_PWCTR1_REG); // ST7735WriteData(0xA202); ST7735WriteData(0x84); ST7735WriteCmd(ST7735_PWCTR2_REG); // set VCL,VGH,VGL,AVDD ST7735WriteData(0xC5); ST7735WriteCmd(ST7735_PWCTR3_REG); // ST7735WriteData(0x0A00); ST7735WriteCmd(ST7735_PWCTR4_REG); // ST7735WriteData(0x8A2A); ST7735WriteCmd(ST7735_PWCTR5_REG); // ST7735WriteData(0x8AEE); ST7735WriteCmd(ST7735_VMCTR1_REG); // ST7735WriteData(0x0E); ST7735WriteCmd(ST7735_MADCTL_REG); //set VCOMH,VCOML voltage ST7735WriteData(0xC8); //VCOMH=3.275V ST7735WriteCmd(ST7735_INVOFF_REG); ST7735WriteCmd(ST7735_INVON_REG); //===== gamma"+"polarity correction characteristic setting =================== ST7735WriteCmd(ST7735_GAMCTRP1_REG); ST7735WriteData(0x21C); ST7735WriteData(0x712); ST7735WriteData(0x3732); ST7735WriteData(0x292D); ST7735WriteData(0x2925); ST7735WriteData(0x2B39); ST7735WriteData(0x1); ST7735WriteData(0x310); //===== gamma"-"polarity correction characteristic setting =================== ST7735WriteCmd(ST7735_GAMCTRN1_REG); ST7735WriteData(0x31D); ST7735WriteData(0x706); ST7735WriteData(0x2E2C); ST7735WriteData(0x292D); ST7735WriteData(0x2E2E); ST7735WriteData(0x373F); ST7735WriteData(0x0); ST7735WriteData(0x210); ST7735WriteCmd(ST7735_INVOFF_REG); // ST7735WriteCmd(ST7735_MADCTL_REG); // memory access control write_data(0xcc); ST7735WriteCmd(ST7735_COLMOD_REG); // E0H or E1 Register enable or disabl write_data(0x05); // E0H or E1 Register enable ST7735WriteCmd(ST7735_DISPON_REG); // display on // // Set the display size and ensure that the GRAM window is set to allow // access to the full display buffer. // ST7735WriteCmd(ST7735_CASET_REG); ST7735WriteData(0); ST7735WriteData(LCD_HORIZONTAL_MAX - 1); ST7735WriteCmd(ST7735_RASET_REG); ST7735WriteData(0); ST7735WriteData(LCD_VERTICAL_MAX - 1); // // Clear the contents of the display buffer. // ST7735WriteCmd(ST7735_RAMWR_REG); for(ulCount = 0; ulCount < (LCD_HORIZONTAL_MAX * LCD_VERTICAL_MAX); ulCount++) { ST7735WriteData(0xFFFF); } }
//***************************************************************************** // //! \brief Init the sensor shield board. //! //! \param None. //! //! Init the sensor shield board. //! //! \return None // //***************************************************************************** void SensorShieldInit(void) { #if(SENSOR_SHIELD_OUT_USED > 0) xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O0); xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O1); xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O2); xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O3); xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O4); xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O5); #endif #if((SENSOR_SHIELD_IN0_USED == SENSOR_SHIELD_IN_ANALOG) || \ (SENSOR_SHIELD_IN1_USED == SENSOR_SHIELD_IN_ANALOG) || \ (SENSOR_SHIELD_IN2_USED == SENSOR_SHIELD_IN_ANALOG) || \ (SENSOR_SHIELD_IN3_USED == SENSOR_SHIELD_IN_ANALOG) || \ (SENSOR_SHIELD_IN4_USED == SENSOR_SHIELD_IN_ANALOG) || \ (SENSOR_SHIELD_IN5_USED == SENSOR_SHIELD_IN_ANALOG)) xSysCtlPeripheralClockSourceSet(xSYSCTL_ADC0_HCLK, 3); // // Enable Peripheral ADC0 // xSysCtlPeripheralEnable(xSYSCTL_PERIPH_ADC0); // // Configure Some GPIO pins as ADC Mode // // // Enable the adc // xADCEnable(xADC0_BASE); // // ADC Channel0 convert once, Software tirgger. // xADCConfigure(xADC0_BASE, xADC_MODE_SCAN_CONTINUOUS, ADC_TRIGGER_PROCESSOR); // // Enable the channel0 // // // Set Compare Condition(Moisture Sensor Limited Value) // xADCCompConditionConfig(ADC_BASE, 0, xADC_COMP_INT_LOW); ADCCompDataSet(ADC_BASE, 0, 1600, 1); xADCCompEnable(ADC_BASE, 0); // // Enable the ADC end of conversion interrupt // xADCIntEnable(xADC0_BASE, xADC_INT_COMP); // // install the call back interrupt // xADCIntCallbackInit(xADC0_BASE, ADCCallback); // // Enable the NVIC ADC interrupt // xIntEnable(xINT_ADC0); xADCProcessorTrigger(xADC0_BASE); #endif #if(SENSOR_SHIELD_IN0_USED == SENSOR_SHIELD_IN_ANALOG) sA0PinTypeADC(); xADCStepConfigure(xADC0_BASE, 1, xADC_CTL_CH0); #elif (SENSOR_SHIELD_IN0_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_A0); #endif #if(SENSOR_SHIELD_IN1_USED == SENSOR_SHIELD_IN_ANALOG) sA1PinTypeADC(); xADCStepConfigure(xADC0_BASE, 1, xADC_CTL_CH1); #elif (SENSOR_SHIELD_IN0_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_A1); #endif #if(SENSOR_SHIELD_IN2_USED == SENSOR_SHIELD_IN_ANALOG) sA2PinTypeADC(); xADCStepConfigure(xADC0_BASE, 1, xADC_CTL_CH2); #elif (SENSOR_SHIELD_IN0_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_A2); #endif #if(SENSOR_SHIELD_IN3_USED == SENSOR_SHIELD_IN_ANALOG) sA3PinTypeADC(); xADCStepConfigure(xADC0_BASE, 1, xADC_CTL_CH3); #elif (SENSOR_SHIELD_IN0_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_A3); #endif #if(SENSOR_SHIELD_IN4_USED == SENSOR_SHIELD_IN_ANALOG) sA4PinTypeADC(); xADCStepConfigure(xADC0_BASE, 1, xADC_CTL_CH4); #elif (SENSOR_SHIELD_IN0_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_A4); #endif #if(SENSOR_SHIELD_IN5_USED == SENSOR_SHIELD_IN_ANALOG) sA5PinTypeADC(); xADCStepConfigure(xADC0_BASE, 1, xADC_CTL_CH5); #elif (SENSOR_SHIELD_IN0_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_A5); #endif #if(SENSOR_SHIELD_I2C_USED > 0) // // Enable the GPIOx port which is connected with I2C // xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_TWI_SDA)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_TWI_SCK)); // // Enable the I2Cx which is connected with device // xSysCtlPeripheralEnable2(sI2C_BASE); // // Set BH1750_PIN_I2C_CLK as CLK // sPinTypeI2C(sI2C_BASE); // // Configure MCU as a master device and Set Clcok Rates // xI2CMasterInit(sI2C_BASE, 100000); xI2CMasterEnable(sI2C_BASE); #endif #if(SENSOR_SHIELD_UART_USED > 0) xSysCtlPeripheralEnable2(sUART_BASE); xSysCtlPeripheralClockSourceSet(xSYSCTL_UART1_MAIN, 1); sPinTypeUART(sUART_BASE); xUARTConfigSet(sUART_BASE, 115200, (xUART_CONFIG_WLEN_8 | xUART_CONFIG_STOP_1 | xUART_CONFIG_PAR_NONE)); #endif }
//***************************************************************************** // //! \brief xgpio001 test execute main body. //! //! \return None. // //***************************************************************************** static void xgpio001Execute(void) { unsigned long ulPin, ulPort; unsigned long ulvalue, ulTemp, ulTemp1; int i, j; // // GPIO mode set and get. // for(ulPort = 0; ulPort < 5; ulPort++) { for(ulPin = 0; ulPin < 16; ulPin++) { for(i = 0; i < 5; i++) { if(ulPort != 1 && ulPort != 3) { xGPIODirModeSet(ulGPIO[ulPort], ulPackedPin[ulPin], ulPinMode[i]); ulvalue = xGPIODirModeGet(ulGPIO[ulPort], ulPackedPin[ulPin]); TestAssert((ulvalue == ulPinMode[i]), "xgpio, \" GPIODirModeSet or GPIODirModeGet()\" error"); } } } } xIntDisable(xINT_GPIOA); xIntDisable(xINT_GPIOB); xIntDisable(xINT_GPIOC); xIntDisable(xINT_GPIOD); xIntDisable(xINT_GPIOE); // // Interrupt enable. // for(ulPort = 0; ulPort < 5; ulPort++) { for(ulPin = 0; ulPin < 16; ulPin++) { for(i = 0; i < 6; i++) { xGPIOPinIntEnable(ulGPIO[ulPort], ulPackedPin[ulPin], ulIntType[i]); if(ulIntType[i] & 0x10) { ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_IMD) & ulPackedPin[ulPin]; TestAssert(ulTemp == ulPackedPin[ulPin], "xgpio, \"Level INT type enable \" error"); } else { ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_IMD) & ulPackedPin[ulPin]; TestAssert(ulTemp == 0, "xgpio, \"Edge INT type enable \" error"); } if(ulIntType[i] & 2) { ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_IEN) & (ulPackedPin[ulPin] << 16); TestAssert(ulTemp == (ulPackedPin[ulPin] << 16), "xgpio, \"Rising or high level Int \" error"); } if(ulIntType[i] & 1) { ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_IEN) & ulPackedPin[ulPin]; TestAssert(ulTemp == ulPackedPin[ulPin], "xgpio, \"Falling or low level Int \" error"); } } } } // // Interrupt disable test // for(ulPort = 0; ulPort < 5; ulPort++) { for(ulPin = 0; ulPin < 16; ulPin++) { xGPIOPinIntDisable(ulGPIO[ulPort], ulPackedPin[ulPin]); ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_IEN) & (ulPackedPin[ulPin] << 16); ulTemp1 = xHWREG(ulGPIO[ulPort] + GPIO_IEN) & ulPackedPin[ulPin]; ulTemp |= ulTemp1; TestAssert(ulTemp == 0, "xgpio, \"Interrupt disable test \" error"); } } // // Pin Out/in value test // for(ulPort = 0; ulPort < 5; ulPort++) { // // Output pin value set // for(ulPin = 0; ulPin < 16; ulPin++) { xGPIODirModeSet( ulGPIO[ulPort], ulPackedPin[ulPin], GPIO_DIR_MODE_OUT ); xGPIOPinWrite(ulGPIO[ulPort], ulPackedPin[ulPin], 1); ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_DOUT) & ulPackedPin[ulPin]; TestAssert(ulTemp == ulPackedPin[ulPin], "xgpio, \"Output pin value set \" error"); } } // // De-bounce enable/disable test // for(ulPort = 0; ulPort < 5; ulPort++) { // // De-bounce enable test // for(ulPin = 0; ulPin < 16; ulPin++) { GPIOPinDebounceEnable(ulGPIO[ulPort], ulPackedPin[ulPin]); ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_DBEN) & ulPackedPin[ulPin]; TestAssert(ulTemp == ulPackedPin[ulPin], "xgpio, \"De-bounce enable test \" error"); } // // De-bounce disable test // for(ulPin = 0; ulPin < 16; ulPin++) { GPIOPinDebounceDisable(ulGPIO[ulPort], ulPackedPin[ulPin]); ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_DBEN) & ulPackedPin[ulPin]; TestAssert(ulTemp == 0, "xgpio, \"De-bounce Disable test \" error"); } } // // Mask set/get test // for(ulPort = 0; ulPort < 5; ulPort++) { for(ulPin = 0; ulPin < 16; ulPin++) { GPIOPinMaskSet(ulGPIO[ulPort], ulPackedPin[ulPin]); ulTemp = GPIOPortMaskGet(ulGPIO[ulPort]) & ulPackedPin[ulPin]; TestAssert(ulTemp == ulPackedPin[ulPin], "xgpio, \" Mask set/get test \" error"); } } // // De-bounce time set and get test // for(i = 0; i < 2; i++) { for(j = 0; j < 3; j++) { GPIODebounceTimeSet(ulDelay[i], ulDelayCycle[j]); ulTemp = xHWREG(GPIO_DBNCECON) & 0x10; if(i == 0) { TestAssert(ulTemp == 0, "xgpio, \" De-bounce source set \" error"); } else { TestAssert(ulTemp == 0x10, "xgpio, \" De-bounce source set \" error"); } ulTemp1 = GPIODebounceTimeGet(); TestAssert(ulTemp1 == ulDelayCycle[j], "xgpio, \" De-bounce cycle test \" error"); } } // // Pin to peripheral ID test // ulTemp = xGPIOSPinToPeripheralId(PA0); TestAssert(ulTemp == ulPeripheralID[0], "xgpio, \" Pin to peripheral ID test \" error"); // // Short pin to pin test // ulTemp = xGPIOSPinToPin(PA0); TestAssert(ulTemp == ulPinValue[0], "xgpio, \" Short pin to pin test \" error"); ulTemp = xGPIOSPinToPin(PB8); TestAssert(ulTemp == ulPinValue[1], "xgpio, \" Short pin to pin test \" error"); ulTemp = xGPIOSPinToPin(PE15); TestAssert(ulTemp == ulPinValue[2], "xgpio, \" Short pin to pin test \" error"); // // Short pin dir mode set test // for(i = 0; i < 5; i++) { xGPIOSPinDirModeSet(PA0, ulPinMode[i]); ulTemp = xGPIODirModeGet(xGPIO_PORTA_BASE, GPIO_PIN_0); TestAssert(ulTemp == ulPinMode[i], "xgpio, \" Short pin dir mode set test \" error"); } // // Short pin interrupt enable // for(i = 0; i < 6; i++) { xGPIOSPinIntEnable(PA0, ulIntType[i]); if(ulIntType[i] & 0x10) { ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_IMD) & GPIO_PIN_0; TestAssert(ulTemp == GPIO_PIN_0, "xgpio, \"ShortPin INT type enable \" error"); } else { ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_IMD) & GPIO_PIN_0; TestAssert(ulTemp == 0, "xgpio, \"ShortPin INT type enable \" error"); } if(ulIntType[i] & 2) { ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_IEN) & (GPIO_PIN_0 << 16); TestAssert(ulTemp == (GPIO_PIN_0 << 16), "xgpio, \"ShortPin INT type enable \" error"); } if(ulIntType[i] & 1) { ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_IEN) & GPIO_PIN_0; TestAssert(ulTemp == GPIO_PIN_0, "xgpio, \"ShortPin INT type enable \" error"); } } // // Short pin interrupt disable // xGPIOSPinIntDisable(PA0); ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_IEN) & (GPIO_PIN_0 << 16); ulTemp1 = xHWREG(xGPIO_PORTA_BASE + GPIO_IEN) & GPIO_PIN_0; ulTemp |= ulTemp1; TestAssert(ulTemp == 0, "xgpio, \"Short pin interrupt disable \" error"); // // Short pin write test // xGPIOSPinWrite(PA0, 1); ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_DOUT) & GPIO_PIN_0; TestAssert(ulTemp == GPIO_PIN_0, "xgpio, \"Short pin write test \" error"); // // Turn pin to gpio mode test // xGPIOSPinTypeGPIOInput(PA0); ulTemp = xHWREG(GCR_GPAMFP) & GPIO_PIN_0; TestAssert(ulTemp == 0, "xgpio, \"Turn pin to gpio mode test \" error"); // // Turn pin to ADC input function // xSPinTypeADC(ADC0, PA0); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP0; TestAssert(ulTemp == GCR_GPAMFP_MFP0, "xgpio, \"Turn pin to ADC0 input \" error"); xSPinTypeADC(ADC1, PA1); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP1; TestAssert(ulTemp == GCR_GPAMFP_MFP1, "xgpio, \"Turn pin to ADC1 input \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_4); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to ADC1 input \" error"); xSPinTypeADC(ADC2, PA2); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP2; TestAssert(ulTemp == GCR_GPAMFP_MFP2, "xgpio, \"Turn pin to ADC2 input \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_3); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to ADC2 input \" error"); xSPinTypeADC(ADC3, PA3); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP3; TestAssert(ulTemp == GCR_GPAMFP_MFP3, "xgpio, \"Turn pin to ADC3 input \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_2); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to ADC3 input \" error"); xSPinTypeADC(ADC4, PA4); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP4; TestAssert(ulTemp == GCR_GPAMFP_MFP4, "xgpio, \"Turn pin to ADC4 input \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_1); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to ADC4 input \" error"); xSPinTypeADC(ADC5, PA5); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP5; TestAssert(ulTemp == GCR_GPAMFP_MFP5, "xgpio, \"Turn pin to ADC5 input \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_0); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to ADC5 input \" error"); xSPinTypeADC(ADC6, PA6); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP6; TestAssert(ulTemp == GCR_GPAMFP_MFP6, "xgpio, \"Turn pin to ADC6 input \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to ADC6 input \" error"); xSPinTypeADC(ADC7, PA7); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP7; TestAssert(ulTemp == GCR_GPAMFP_MFP7, "xgpio, \"Turn pin to ADC7 input \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to ADC7 input \" error"); ulTemp = xHWREG(GCR_ALTMFP) & GCR_ALTMFP_PA7_S21; TestAssert(ulTemp == 0, "xgpio, \"Turn pin to ADC7 input \" error"); // // Ture pin to I2C function // xSPinTypeI2C(I2C0SCK, PA9); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP9; TestAssert(ulTemp == GCR_GPAMFP_MFP9, "xgpio, \"Turn pin to I2C input \" error"); xSPinTypeI2C(I2C0SDA, PA8); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP8; TestAssert(ulTemp == GCR_GPAMFP_MFP8, "xgpio, \"Turn pin to I2C input \" error"); xSPinTypeI2C(I2C1SCK, PA11); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP11; TestAssert(ulTemp == GCR_GPAMFP_MFP11, "xgpio, \"Turn pin to I2C input \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to I2C input \" error"); xSPinTypeI2C(I2C1SDA, PA10); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP10; TestAssert(ulTemp == GCR_GPAMFP_MFP10, "xgpio, \"Turn pin to I2C input \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to I2C input \" error"); // // Turn pin to CAN function // xSPinTypeCAN(CAN0RX, PD6); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP6; TestAssert(ulTemp == GCR_GPDMFP_MFP6, "xgpio, \"Turn pin to CAN function \" error"); xSPinTypeCAN(CAN0TX, PD7); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP7; TestAssert(ulTemp == GCR_GPDMFP_MFP7, "xgpio, \"Turn pin to CAN function \" error"); // // Turn pin to I2S function // xSPinTypeI2S(I2S0RXMCLK, PA15); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP15; TestAssert(ulTemp == GCR_GPAMFP_MFP15, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & GCR_ALTMFP_PA15_I2SMCLK; TestAssert(ulTemp == GCR_ALTMFP_PA15_I2SMCLK, "xgpio, \"Turn pin to I2S function \" error"); xSPinTypeI2S(I2S0RXSCK, PC1); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP1; TestAssert(ulTemp == GCR_GPCMFP_MFP1, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC1_I2SBCLK); TestAssert(ulTemp == GCR_ALTMFP_PC1_I2SBCLK, "xgpio, \"Turn pin to I2S function \" error"); xSPinTypeI2S(I2S0RXSD, PC2); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP2; TestAssert(ulTemp == GCR_GPCMFP_MFP2, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC2_I2SDI); TestAssert(ulTemp == GCR_ALTMFP_PC2_I2SDI, "xgpio, \"Turn pin to I2S function \" error"); xSPinTypeI2S(I2S0RXWS, PC0); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP0; TestAssert(ulTemp == GCR_GPCMFP_MFP0, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC0_I2SLRCLK); TestAssert(ulTemp == GCR_ALTMFP_PC0_I2SLRCLK, "xgpio, \"Turn pin to I2S function \" error"); xSPinTypeI2S(I2S0TXMCLK, PA15); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP15; TestAssert(ulTemp == GCR_GPAMFP_MFP15, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & GCR_ALTMFP_PA15_I2SMCLK; TestAssert(ulTemp == GCR_ALTMFP_PA15_I2SMCLK, "xgpio, \"Turn pin to I2S function \" error"); xSPinTypeI2S(I2S0TXSCK, PC1); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP1; TestAssert(ulTemp == GCR_GPCMFP_MFP1, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC1_I2SBCLK); TestAssert(ulTemp == GCR_ALTMFP_PC1_I2SBCLK, "xgpio, \"Turn pin to I2S function \" error"); xSPinTypeI2S(I2S0TXSD, PC3); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP3; TestAssert(ulTemp == GCR_GPCMFP_MFP3, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC3_I2SDO); TestAssert(ulTemp == GCR_ALTMFP_PC3_I2SDO, "xgpio, \"Turn pin to I2S function \" error"); xSPinTypeI2S(I2S0TXWS, PC0); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP0; TestAssert(ulTemp == GCR_GPCMFP_MFP0, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC0_I2SLRCLK); TestAssert(ulTemp == GCR_ALTMFP_PC0_I2SLRCLK, "xgpio, \"Turn pin to I2S function \" error"); // // Turn pin to pwm mode // xSPinTypePWM(PWM0, PA12); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP12; TestAssert(ulTemp == GCR_GPAMFP_MFP12, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_5); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to PWM input \" error"); xSPinTypePWM(PWM1, PA13); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP13; TestAssert(ulTemp == GCR_GPAMFP_MFP13, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_6); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to PWM input \" error"); xSPinTypePWM(PWM2, PA14); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP14; TestAssert(ulTemp == GCR_GPAMFP_MFP14, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_7); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to PWM input \" error"); xSPinTypePWM(PWM3, PA15); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP15; TestAssert(ulTemp == GCR_GPAMFP_MFP15, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & GCR_ALTMFP_PA15_I2SMCLK; TestAssert(ulTemp == 0, "xgpio, \"Turn pin to PWM function \" error"); xSPinTypePWM(PWM4, PB11); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP11; TestAssert(ulTemp == GCR_GPBMFP_MFP11, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB11_PWM4); TestAssert(ulTemp == GCR_ALTMFP_PB11_PWM4, "xgpio, \"Turn pin to PWM input \" error"); xSPinTypePWM(PWM5, PE5); ulTemp = xHWREG(GCR_GPEMFP) & GCR_GPEMFP_MFP5; TestAssert(ulTemp == GCR_GPEMFP_MFP5, "xgpio, \"Turn pin to I2S function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PE5_T1EX); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to PWM input \" error"); xSPinTypePWM(PWM6, PE0); ulTemp = xHWREG(GCR_GPEMFP) & GCR_GPEMFP_MFP0; TestAssert(ulTemp == GCR_GPEMFP_MFP0, "xgpio, \"Turn pin to PWM function \" error"); xSPinTypePWM(PWM7, PE1); ulTemp = xHWREG(GCR_GPEMFP) & GCR_GPEMFP_MFP1; TestAssert(ulTemp == GCR_GPEMFP_MFP1, "xgpio, \"Turn pin to PWM function \" error"); // // Turn pin to spi function test // xSPinTypeSPI(SPI0CLK, PC1); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP1; TestAssert(ulTemp == GCR_GPCMFP_MFP1, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC1_I2SBCLK); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0MOSI, PC5); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP5; TestAssert(ulTemp == GCR_GPCMFP_MFP5, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0MOSI, PC3); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP3; TestAssert(ulTemp == GCR_GPCMFP_MFP3, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0MISO, PC2); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP2; TestAssert(ulTemp == GCR_GPCMFP_MFP2, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC2_I2SDI); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to I2S function \" error"); xSPinTypeSPI(SPI0MISO, PC4); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP4; TestAssert(ulTemp == GCR_GPCMFP_MFP4, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0CS, PC0); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP0; TestAssert(ulTemp == GCR_GPCMFP_MFP0, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC0_I2SLRCLK); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0CS, PB10); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP10; TestAssert(ulTemp == GCR_GPBMFP_MFP10, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB10_S01); TestAssert(ulTemp == GCR_ALTMFP_PB10_S01, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0CS, PC0); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP0; TestAssert(ulTemp == GCR_GPCMFP_MFP0, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI1MOSI, PC13); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP13; TestAssert(ulTemp == GCR_GPCMFP_MFP13, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI1MOSI, PC11); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP11; TestAssert(ulTemp == GCR_GPCMFP_MFP11, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI1MISO, PC12); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP12; TestAssert(ulTemp == GCR_GPCMFP_MFP12, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI1MISO, PC10); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP10; TestAssert(ulTemp == GCR_GPCMFP_MFP10, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI1CS, PB9); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP9; TestAssert(ulTemp == GCR_GPBMFP_MFP9, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB9_S11); TestAssert(ulTemp == GCR_ALTMFP_PB9_S11, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI1CS, PC8); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP8; TestAssert(ulTemp == GCR_GPCMFP_MFP8, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI2CLK, PD1); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP1; TestAssert(ulTemp == GCR_GPDMFP_MFP1, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI2MOSI, PD3); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP3; TestAssert(ulTemp == GCR_GPDMFP_MFP3, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI2MOSI, PD5); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP5; TestAssert(ulTemp == GCR_GPDMFP_MFP5, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI2MISO, PD4); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP4; TestAssert(ulTemp == GCR_GPDMFP_MFP4, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI2MISO, PD2); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP2; TestAssert(ulTemp == GCR_GPDMFP_MFP2, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI2CS, PA7); ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP7; TestAssert(ulTemp == GCR_GPAMFP_MFP7, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PA7_S21); TestAssert(ulTemp == GCR_ALTMFP_PA7_S21, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI2CS, PD0); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP0; TestAssert(ulTemp == GCR_GPDMFP_MFP0, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI3CLK, PD9); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP9; TestAssert(ulTemp == GCR_GPDMFP_MFP9, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI3MOSI, PD11); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP11; TestAssert(ulTemp == GCR_GPDMFP_MFP11, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI3MOSI, PD13); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP13; TestAssert(ulTemp == GCR_GPDMFP_MFP13, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI3MISO, PD10); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP10; TestAssert(ulTemp == GCR_GPDMFP_MFP10, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI3MISO, PD12); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP12; TestAssert(ulTemp == GCR_GPDMFP_MFP12, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI3CS, PB14); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP14; TestAssert(ulTemp == GCR_GPBMFP_MFP14, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB14_S31); TestAssert(ulTemp == GCR_ALTMFP_PB14_S31, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI3CS, PD8); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP8; TestAssert(ulTemp == GCR_GPDMFP_MFP8, "xgpio, \"Turn pin to SPI function \" error"); // // Turn pin to timer function test // xSPinTypeTimer(TIMCCP0, PB8); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP8; TestAssert(ulTemp == GCR_GPBMFP_MFP8, "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP1, PB9); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP9; TestAssert(ulTemp == GCR_GPBMFP_MFP9, "xgpio, \"Turn pin to TIMER function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB9_S11); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP2, PB10); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP10; TestAssert(ulTemp == GCR_GPBMFP_MFP10, "xgpio, \"Turn pin to TIMER function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB10_S01); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP3, PB11); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP11; TestAssert(ulTemp == GCR_GPBMFP_MFP11, "xgpio, \"Turn pin to TIMER function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB11_PWM4); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to TIMER function \" error"); // // Turn pin to uart function test // xSPinTypeUART(UART0RX, PB0); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP0; TestAssert(ulTemp == GCR_GPBMFP_MFP0, "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0TX, PB1); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP1; TestAssert(ulTemp == GCR_GPBMFP_MFP1, "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0RTS, PB2); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP2; TestAssert(ulTemp == GCR_GPBMFP_MFP2, "xgpio, \"Turn pin to UART function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_nWRL_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to UART function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB2_T2EX); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0CTS, PB3); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP3; TestAssert(ulTemp == GCR_GPBMFP_MFP3, "xgpio, \"Turn pin to UART function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_nWRH_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to UART function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB3_T3EX); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART1RTS, PB6); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP6; TestAssert(ulTemp == GCR_GPBMFP_MFP6, "xgpio, \"Turn pin to UART function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART1RX, PB4); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP4; TestAssert(ulTemp == GCR_GPBMFP_MFP4, "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART1TX, PB5); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP5; TestAssert(ulTemp == GCR_GPBMFP_MFP5, "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART2RX, PD14); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP14; TestAssert(ulTemp == GCR_GPDMFP_MFP14, "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART2TX, PD15); ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP15; TestAssert(ulTemp == GCR_GPDMFP_MFP15, "xgpio, \"Turn pin to UART function \" error"); // // Turn pin to ACMP function test // xSPinTypeACMP(CMP0P, PC6); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP6; TestAssert(ulTemp == GCR_GPCMFP_MFP6, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeACMP(CMP0N, PC7); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP7; TestAssert(ulTemp == GCR_GPCMFP_MFP7, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeACMP(CMP0O, PB12); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP12; TestAssert(ulTemp == GCR_GPBMFP_MFP12, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeACMP(CMP1P, PC14); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP14; TestAssert(ulTemp == GCR_GPCMFP_MFP14, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeACMP(CMP1N, PC15); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP15; TestAssert(ulTemp == GCR_GPCMFP_MFP15, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeACMP(CMP1O, PB13); ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP13; TestAssert(ulTemp == GCR_GPBMFP_MFP13, "xgpio, \"Turn pin to SPI function \" error"); ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN); TestAssert(ulTemp == 0, "xgpio, \"Turn pin to SPI function \" error"); }
//***************************************************************************** // //! \brief Initialize the sensor shield board. //! //! \param None. //! //! Initialize the sensor shield board. //! //! \return None // //***************************************************************************** void SensorShieldInit(void) { xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_O0)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_O1)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_O2)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_O3)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_O4)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_O5)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_I0)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_I1)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_I2)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_I3)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_I4)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_I5)); #if(SENSOR_SHIELD_OUT_USED > 0) xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O0); xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O1); xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O2); xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O3); xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O4); xGPIOSPinTypeGPIOOutput(SENSOR_SHIELD_O5); //xSysCtlPeripheralEnable2(); #endif #if((SENSOR_SHIELD_IN0_USED == SENSOR_SHIELD_IN_ANALOG) || \ (SENSOR_SHIELD_IN1_USED == SENSOR_SHIELD_IN_ANALOG) || \ (SENSOR_SHIELD_IN2_USED == SENSOR_SHIELD_IN_ANALOG) || \ (SENSOR_SHIELD_IN3_USED == SENSOR_SHIELD_IN_ANALOG) || \ (SENSOR_SHIELD_IN4_USED == SENSOR_SHIELD_IN_ANALOG) || \ (SENSOR_SHIELD_IN5_USED == SENSOR_SHIELD_IN_ANALOG)) xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(sD45)); // // Set ADCCLK prescaler, ADCCLK=PCLK2(max 72MHz)/Div(Div:2,4,6,8) // You should set ADCCLK < 14MHz to ensure the accuracy of ADC // xSysCtlPeripheralClockSourceSet(xSYSCTL_ADC0_MAIN, 8); // // Enable Peripheral ADC clock // xSysCtlPeripheralEnable(xSYSCTL_PERIPH_ADC1); // // Enable the ADC conversion // xADCEnable(sADC_BASE); // // The two sentences below configure ADC to scan mode, continuous convert, software trigger. // xADCConfigure(sADC_BASE, xADC_MODE_SCAN_SINGLE_CYCLE, ADC_TRIGGER_PROCESSOR); xADCConfigure(sADC_BASE, xADC_MODE_SCAN_CONTINUOUS, ADC_TRIGGER_PROCESSOR); // // Configure channel step by step.(Max 4 steps, the 2nd parameter start from 0, max is 3) // Must not jump over a step, or the ADC result may be in wrong position. // xADCStepConfigure(sADC_BASE, 0, sADC_CH0); xADCStepConfigure(sADC_BASE, 1, sADC_CH1); xADCStepConfigure(sADC_BASE, 2, sADC_CH2); xADCStepConfigure(sADC_BASE, 3, sADC_CH3); #endif #if(SENSOR_SHIELD_IN0_USED == SENSOR_SHIELD_IN_ANALOG) sA0PinTypeADC(); #elif (SENSOR_SHIELD_IN0_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_I0); #endif #if(SENSOR_SHIELD_IN1_USED == SENSOR_SHIELD_IN_ANALOG) sA1PinTypeADC(); #elif (SENSOR_SHIELD_IN1_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_I1); #endif #if(SENSOR_SHIELD_IN2_USED == SENSOR_SHIELD_IN_ANALOG) sA2PinTypeADC(); #elif (SENSOR_SHIELD_IN2_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_I2); #endif #if(SENSOR_SHIELD_IN3_USED == SENSOR_SHIELD_IN_ANALOG) sA3PinTypeADC(); #elif (SENSOR_SHIELD_IN3_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_I3); #endif #if(SENSOR_SHIELD_IN4_USED == SENSOR_SHIELD_IN_ANALOG)|| \ (SENSOR_SHIELD_IN4_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_I4); #endif #if(SENSOR_SHIELD_IN5_USED == SENSOR_SHIELD_IN_ANALOG)|| \ (SENSOR_SHIELD_IN5_USED == SENSOR_SHIELD_IN_DIGITAL) xGPIOSPinTypeGPIOInput(SENSOR_SHIELD_I5); #endif #if(SENSOR_SHIELD_I2C_USED > 0) // // Enable the GPIOx port which is connected with I2C // xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_TWI_SDA)); xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(SENSOR_SHIELD_TWI_SCK)); // // Enable the I2Cx which is connected with device // xSysCtlPeripheralEnable2(sI2C_BASE); // // Set BH1750_PIN_I2C_CLK as CLK // sPinTypeI2C(sI2C_BASE); // // Configure MCU as a master device and Set Clcok Rates // xI2CMasterInit(sI2C_BASE, 100000); xI2CMasterEnable(sI2C_BASE); #endif #if(SENSOR_SHIELD_UART_USED > 0) xSysCtlPeripheralEnable2(sUART_BASE); // xSysCtlPeripheralClockSourceSet(xSYSCTL_UART1_MAIN, 1); sPinTypeUART(sUART_BASE); xUARTConfigSet(sUART_BASE, 115200, (xUART_CONFIG_WLEN_8 | xUART_CONFIG_STOP_1 | xUART_CONFIG_PAR_NONE)); #endif }