int main(void) { uint32_t ui32ADC0Value[4]; ui32TempSet = 25; // Set System CLock SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // Enaable UART SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // Enable GPIO SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Enable ADC Peripheral SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //Allow the ADC12 to run at its default rate of 1Msps. ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0); //our code will average all four samples of temperature sensor data ta on sequencer 1 to calculate the temperature, so all four sequencer steps will measure the temperature sensor ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END); //enable ADC sequencer 1. ADCSequenceEnable(ADC0_BASE, 1); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); IntMasterEnable(); IntEnable(INT_UART0); UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_3); // Set bit rate fr serial communication UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); while (1) { //indication that the ADC conversion process is complete ADCIntClear(ADC0_BASE, 1); //trigger the ADC conversion with software ADCProcessorTrigger(ADC0_BASE, 1); //wait for the conversion to complete while(!ADCIntStatus(ADC0_BASE, 1, false)) { } //read the ADC value from the ADC Sample Sequencer 1 FIFO ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value); ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4; ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10; ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5; print_temp(ui32TempValueC); SysCtlDelay(SysCtlClockGet() / 3); //delay ~1 sec if(ui32TempValueC < ui32TempSet) GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 8); else GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 2); } }
void LCD_BlackLight_Disable (void) { GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_6, 0x00); }
/** * Initialize the processor hardware. * * \req \req_init The \program \shall initialize the hardware. */ void prvSetupHardware(void) { /* * If running on Rev A2 silicon, turn the LDO voltage up to 2.75V. * This is a workaround to allow the PLL to operate reliably. */ if( REVISION_IS_A2 ) { SysCtlLDOSet( SYSCTL_LDO_2_75V ); } /** * Set the clocking to run from the PLL at 50 MHz */ #if (PART == LM3S8962) SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ ); #elif (PART == LM3S9B96) SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ ); /* 80MHz operation, change FreeRTOSConfig.h too */ /* SysCtlClockSet( SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ ); */ #elif (PART == LM3S2110) // // Set the clocking to run directly from the PLL at 25MHz. // SysCtlClockSet(SYSCTL_SYSDIV_8 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); #endif /* * Initialize the ARM peripherals that are used. All the GPIOs * are initialized because the processor I/O page references * all of them. */ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM); #if (PART != LM3S2110) SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); #endif #if (PART==LM3S8962) /* * Configure the GPIOs used to read the on-board buttons. */ GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); /* * Configure the LED and speaker GPIOs. */ GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_1); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0); #endif /* * UART0 is our debug ("spew") I/O. Configure it for 115200, * 8-N-1 operation. */ GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, ( UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE )); }
void GpioOut::off(void) { // Set the pin low GPIOPinWrite(gpio_.port, gpio_.pin, 0); }
//***************************************************************************** // // The main code for the application. It sets up the peripherals, displays the // splash screens, and then manages the interaction between the game and the // screen saver. // //***************************************************************************** int main(void) { // // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V. This is // a workaround to allow the PLL to operate reliably. // if(REVISION_IS_A2) { SysCtlLDOSet(SYSCTL_LDO_2_75V); } // // Set the clocking to run at 50MHz from the PLL. // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); SysCtlPWMClockSet(SYSCTL_PWMDIV_8); // // Get the system clock speed. // g_ulSystemClock = SysCtlClockGet(); // // Enable the peripherals used by the application. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // // Configure the GPIOs used to read the state of the on-board push buttons. // GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // // Configure the LED, speaker, and UART GPIOs as required. // GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_1); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0); // // Initialize the CAN controller. // CANConfigure(); // // Intialize the Ethernet Controller and TCP/IP Stack. // EnetInit(); // // Configure the first UART for 115,200, 8-N-1 operation. // UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTEnable(UART0_BASE); // // Send a welcome message to the UART. // UARTCharPut(UART0_BASE, 'W'); UARTCharPut(UART0_BASE, 'e'); UARTCharPut(UART0_BASE, 'l'); UARTCharPut(UART0_BASE, 'c'); UARTCharPut(UART0_BASE, 'o'); UARTCharPut(UART0_BASE, 'm'); UARTCharPut(UART0_BASE, 'e'); UARTCharPut(UART0_BASE, '\r'); UARTCharPut(UART0_BASE, '\n'); // // Initialize the OSRAM OLED display. // RIT128x96x4Init(3500000); // // Initialize the PWM for generating music and sound effects. // AudioOn(); // // Configure SysTick to periodically interrupt. // SysTickPeriodSet(g_ulSystemClock / CLOCK_RATE); SysTickIntEnable(); SysTickEnable(); // // Delay for a bit to allow the initial display flash to subside. // Delay(CLOCK_RATE / 4); // // Play the intro music. // AudioPlaySong(g_pusIntro, sizeof(g_pusIntro) / 2); // // Display the Texas Instruments logo for five seconds (or twelve seconds // if built using gcc). // #if defined(gcc) DisplayLogo(g_pucTILogo, 120, 42, 12 * CLOCK_RATE); #else DisplayLogo(g_pucTILogo, 120, 42, 5 * CLOCK_RATE); #endif // // Display the Code Composer Studio logo for five seconds. // #if defined(ccs) DisplayLogo(g_pucCodeComposer, 128, 34, 5 * CLOCK_RATE); #endif // // Display the Keil/ARM logo for five seconds. // #if defined(rvmdk) || defined(__ARMCC_VERSION) DisplayLogo(g_pucKeilLogo, 128, 40, 5 * CLOCK_RATE); #endif // // Display the IAR logo for five seconds. // #if defined(ewarm) DisplayLogo(g_pucIarLogo, 102, 61, 5 * CLOCK_RATE); #endif // // Display the CodeSourcery logo for five seconds. // #if defined(sourcerygxx) DisplayLogo(g_pucCodeSourceryLogo, 128, 34, 5 * CLOCK_RATE); #endif // // Display the CodeRed logo for five seconds. // #if defined(codered) DisplayLogo(g_pucCodeRedLogo, 128, 32, 5 * CLOCK_RATE); #endif // // Throw away any button presses that may have occurred while the splash // screens were being displayed. // HWREGBITW(&g_ulFlags, FLAG_BUTTON_PRESS) = 0; // // Loop forever. // while(1) { // // Display the main screen. // if(MainScreen()) { // // The button was pressed, so start the game. // PlayGame(); } else { // // The button was not pressed during the timeout period, so start // the screen saver. // ScreenSaver(); } } }
// *************** GPIO_Write *************** void GPIO_Write( GPIO_PORT_T port, GPIO_PIN_T pins, unsigned char val ) { GPIOPinWrite(GPIO_PortBase[port], pins, val); }
int main(void) { char cThisChar; /* Result code */ unsigned long ulResetCause; //SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); unsigned long g=SysCtlClockGet(); FPUEnable(); FPUStackingEnable(); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); ulResetCause = SysCtlResetCauseGet(); SysCtlResetCauseClear(ulResetCause); HibernateEnableExpClk(SysCtlClockGet()); ButtonsInit(); SysTickPeriodSet(SysCtlClockGet() / APP_SYSTICKS_PER_SEC); SysTickEnable(); SysTickIntEnable(); IntMasterEnable(); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); GPIOPinConfigure(GPIO_PC4_U4RX); GPIOPinConfigure(GPIO_PC5_U4TX); GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5); UARTConfigSetExpClk(UART4_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB0_U1RX); GPIOPinConfigure(GPIO_PB1_U1TX); GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); //Orden al PGS de que me devuelva solo un mensaje.. for(i=0; i<sizeof(buferA); i++){ UARTCharPut(UART1_BASE, buferA[i]);} GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); rc = f_mount(0, &Fatfs); //registra un area de trabajo rc = f_open(&Fil, "BuffGPS.TXT", FA_WRITE | FA_CREATE_ALWAYS); //abre o crea un archivo do { int contador1=0; cThisChar='0'; do{ cThisChar=UARTCharGet(UART1_BASE); BuffGPS[contador1]=cThisChar; contador1=contador1+1; } while((cThisChar != '\n')); cThisChar='0'; for(i=0; i<sizeof(cuaternion); i++){ UARTCharPut(UART4_BASE, cuaternion[i]);} do{ cThisChar=UARTCharGet(UART4_BASE); BuffGPS[contador1]=cThisChar; contador1=contador1+1; } while((cThisChar != '\n')); rc = f_write(&Fil, &BuffGPS, contador1, &bwGPS); rc = f_sync(&Fil); contador1=0; //while(UARTCharsAvail(UART1_BASE)==false){;} } while(1); }
void setL0(bool on) { GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, on << 1); }
void setL2(bool on) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, on << 4); }
void LEDClass::clear() { GPIOPinWrite(GPIO_PORT_BASE, GPIO_PIN, 0x00); }
void LEDClass::set() { GPIOPinWrite(GPIO_PORT_BASE, GPIO_PIN, 0xff); }
int main(void) { /*Set the clocking to run at 80Mhz from the crystal of 16MHz using PLL*/ SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); /* Set the clock for the GPIO Port A,B, E and F */ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); /* Set the type of the GPIO Pin */ GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3); /* Set the clock for the SSI Module0 */ SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0); //Initialising UART InitConsole(); /*Configure SysTick for a 100Hz interrupt. The FatFs driver wants a 10 milliseconds interrupt.*/ SysTickPeriodSet(SysCtlClockGet() / 10000); SysTickIntRegister(SysTickHandler); SysTickEnable(); SysTickIntEnable(); /* Set the type of the GPIO Pin of PORTF */ GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2 ); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4); /* GPIO Pin2 on PORT F initialized to 0 */ GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2 , 0 ); /* Configure GPIO pad with internal pull-up enabled */ GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); /* Enable global interupts */ IntMasterEnable(); UARTprintf("MOUNT initialize!!!\n"); rc=f_mount(0, &fatfs); // Register volume work area (never fails) if(rc!=FR_OK) { UARTprintf("1.rc=%d\nERROR MOUNT!!!",rc); } /* Reset and Initialise the LCD */ TSLCDRst(); TSLCDInit(); setBitBL; /* TFT Home Display */ TSLCDFillRect(0,TS_SIZE_X-1,0,TS_SIZE_Y-1,TS_COL_AQUA,TS_MODE_NORMAL); TSLCDFillRect(0,TS_SIZE_X-1,120,200,TS_COL_YELLOW,TS_MODE_NORMAL); TSLCDSetFontColor(TS_COL_RED); TSLCDPrintStr(4,0,"Tiva Launchpad Based .BMP Image Display ",TS_MODE_NORMAL); TSLCDPrintStr(5,0," TI-CEPD, NSIT ",TS_MODE_NORMAL); TSLCDShowPic(157,175,218,236,smile,TS_MODE_FULL); while(1) { while(GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)!=0); SysCtlDelay(SysCtlClockGet()/100); flag1++; flag2=0; if(flag1==8) flag1=1; if(flag2==0) { //Opening test1.bmp if(flag1==1) { rc=f_open(&fil,"test1.bmp",FA_OPEN_EXISTING|FA_WRITE|FA_READ); SysCtlDelay(SysCtlClockGet()/100); // UARTprintf("Test1::::\n"); if(rc!=FR_OK) { UARTprintf("2.rc=%d\n ERROR OPEN!!!\n",rc); } } //Opening test2.bmp else if((flag1==2)&&(flag2==0)) { rc=f_open(&fil,"test2.bmp",FA_OPEN_EXISTING|FA_WRITE|FA_READ); SysCtlDelay(SysCtlClockGet()/100); // UARTprintf("Test2::::\n"); if(rc!=FR_OK) { UARTprintf("2.rc=%d\n ERROR OPEN!!!\n",rc); } } //Opening test3.bmp else if((flag1==3)&&(flag2==0)) { rc=f_open(&fil,"test3.bmp",FA_OPEN_EXISTING|FA_WRITE|FA_READ); SysCtlDelay(SysCtlClockGet()/100); // UARTprintf("Test3::::\n"); if(rc!=FR_OK) { UARTprintf("2.rc=%d\n ERROR OPEN!!!\n",rc); } } //Opening test4.bmp else if((flag1==4)&&(flag2==0)) { rc=f_open(&fil,"test4.bmp",FA_OPEN_EXISTING|FA_WRITE|FA_READ); SysCtlDelay(SysCtlClockGet()/100); // UARTprintf("Test4::::\n"); if(rc!=FR_OK) { UARTprintf("2.rc=%d\n ERROR OPEN!!!\n",rc); } } //Opening test5.bmp else if((flag1==5)&&(flag2==0)) { rc=f_open(&fil,"test5.bmp",FA_OPEN_EXISTING|FA_WRITE|FA_READ); SysCtlDelay(SysCtlClockGet()/100); // UARTprintf("Test4::::\n"); if(rc!=FR_OK) { UARTprintf("2.rc=%d\n ERROR OPEN!!!\n",rc); } } //Opening test6.bmp else if((flag1==6)&&(flag2==0)) { rc=f_open(&fil,"test6.bmp",FA_OPEN_EXISTING|FA_WRITE|FA_READ); SysCtlDelay(SysCtlClockGet()/100); // UARTprintf("Test4::::\n"); if(rc!=FR_OK) { UARTprintf("2.rc=%d\n ERROR OPEN!!!\n",rc); } } //Opening test7.bmp else if((flag1==7)&&(flag2==0)) { rc=f_open(&fil,"test7.bmp",FA_OPEN_EXISTING|FA_WRITE|FA_READ); SysCtlDelay(SysCtlClockGet()/100); // UARTprintf("Test4::::\n"); if(rc!=FR_OK) { UARTprintf("2.rc=%d\n ERROR OPEN!!!\n",rc); } } //Setting background colour TSLCDFillRect(0,TS_SIZE_X-1,0,TS_SIZE_Y-1,TS_COL_AQUA,TS_MODE_NORMAL); //Printing Image data rc=f_read(&fil,&dummy,10, &br); //Reading bmp offset address 10 or 0xA rc=f_read(&fil,&addr,4, &br); // UARTprintf("address::%04d\n",addr); rc=f_read(&fil,&dummy,4, &br); //Reading Width at address 18 or 0x12 rc=f_read(&fil,&width,4, &br); // UARTprintf("width::%04d\n",width); //Reading height at address 22 or 0x16 rc=f_read(&fil,&height,4, &br); // UARTprintf("height::%04d\n",height); rc=f_read(&fil,&dummy,4, &br); //Reading compression method of image at address 30 or 0x1E rc=f_read(&fil,&c_method,4, &br); // UARTprintf("Compression method::%04d\n",c_method); rc=f_read(&fil,&dummy,addr-34, &br); //Finding the number of bytes for padding remainder=(width*3)%4; if(remainder!=0) { remainder=4-remainder; } // UARTprintf("dummy bytes::%04d\n",remainder); //Setting the offset to display the image in centre _height=120+height/2; //Reading Bitmap data at address::54 for(j=1;j<=height;j++) { for(i=1;i<=width;i++) { rc=f_read(&fil,&pix1,1, &br); rc=f_read(&fil,&pix2,1, &br); rc=f_read(&fil,&pix3,1, &br); _pix1=pix1/8; _pix2=pix2/4; _pix3=pix3/8; /* UARTprintf("blue::%04d\n",pix1); UARTprintf("blue::%04d\n",_pix1<<11); UARTprintf("green::%06d\n",pix2); UARTprintf("green::%06d\n",_pix2<<5); UARTprintf("red::%04d\n",pix3); UARTprintf("red::%04d\n",_pix3); */ tft_pix=(_pix1<<11)+(_pix2<<5)+_pix3; // UARTprintf("tft pix::%04d\n",tft_pix); pix[i-1]=tft_pix; } TSLCDShowPic(160-(width/2),159+(width/2),_height-j,_height-j,pix,TS_MODE_FULL); rc=f_read(&fil,&dummy,remainder, &br); } rc = f_close(&fil); flag2=1; } } return 0; }
//***************************************************************************** // //! Initialize the OLED display. //! //! \param bFast is a boolean that is \e true if the I2C interface should be //! run at 400 kbps and \e false if it should be run at 100 kbps. //! //! This function initializes the I2C interface to the OLED display and //! configures the SSD0303 or SSD1300 controller on the panel. //! //! \return None. // //***************************************************************************** void Display96x16x1Init(tBoolean bFast) { unsigned long ulIdx; // // The power supply for the OLED display comes from the motor power // supply, which must be turned on. If the application is using the // motor then this is taken care of when the motor driver is initialized. // But if the motor driver is not used, then the motor power supply needs // to be turned on here so the OLED works properly. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_5); GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_5, GPIO_PIN_5); // // Enable the I2C and GPIO peripherals needed for the display. // SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); // // Deassert the display controller reset signal (active low) // GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0); // // Wait a short delay, then drive the pin low to reset the controller // SysCtlDelay(32); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0); // // Leave it is reset for a short delay, then drive it high to deassert // reset. Then the controller should be out of reset. // SysCtlDelay(32); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0); // // Configure the GPIO pins needed for the display as I2C // GPIOPinConfigure(GPIO_PG0_I2C1SCL); GPIOPinConfigure(GPIO_PG1_I2C1SDA); GPIOPinTypeI2C(GPIO_PORTG_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Reset the I2C1 peripheral. // SysCtlPeripheralReset(SYSCTL_PERIPH_I2C1); // // Initialize the I2C master. // I2CMasterInitExpClk(I2C1_MASTER_BASE, SysCtlClockGet(), bFast); // // Initialize the display controller. Loop through the initialization // sequence doing a single I2C transfer for each command. // for(ulIdx = 0; ulIdx < sizeof(g_pucRITInit); ulIdx += g_pucRITInit[ulIdx] + 1) { // // Send this command. // Display96x16x1WriteFirst(g_pucRITInit[ulIdx + 1]); Display96x16x1WriteArray(g_pucRITInit + ulIdx + 2, g_pucRITInit[ulIdx] - 2); Display96x16x1WriteFinal(g_pucRITInit[ulIdx + g_pucRITInit[ulIdx]]); } // // Clear the frame buffer. // Display96x16x1Clear(); // // Turn the display on. // Display96x16x1DisplayOn(); }
//***************************************************************************** //! Handles the UART interrupt. //! //! \param ucPort is the serial port number to be accessed. //! //! This function is called when either of the UARTs generate an interrupt. //! An interrupt will be generated when data is received and when the transmit //! FIFO becomes half empty. The transmit and receive FIFOs are processed as //! appropriate. //! //! \return None. //***************************************************************************** static void SerialUARTIntHandler(uint8_t ucPort) { // Get the cause of the interrupt. uint32_t ulStatus = UARTIntStatus(g_ulUARTBase[ucPort], true); // Clear the cause of the interrupt. UARTIntClear(g_ulUARTBase[ucPort], ulStatus); // See if there is data to be processed in the receive FIFO. if(ulStatus & (UART_INT_RT | UART_INT_RX)) { // Loop while there are characters available in the receive FIFO. while(UARTCharsAvail(g_ulUARTBase[ucPort])) { // Get the next character from the receive FIFO. uint8_t ucChar = UARTCharGet(g_ulUARTBase[ucPort]); #ifdef PROTOCOL_TELNET // If Telnet protocol enabled, check for incoming IAC character, // and escape it. if((g_sParameters.sPort[ucPort].ucFlags & PORT_FLAG_PROTOCOL) == PORT_PROTOCOL_TELNET) { // If this is a Telnet IAC character, write it twice. if((ucChar == TELNET_IAC) && (RingBufFree(&g_sRxBuf[ucPort]) >= 2)) { RingBufWriteOne(&g_sRxBuf[ucPort], ucChar); RingBufWriteOne(&g_sRxBuf[ucPort], ucChar); } // If not a Telnet IAC character, only write it once. else if((ucChar != TELNET_IAC) && (RingBufFree(&g_sRxBuf[ucPort]) >= 1)) { RingBufWriteOne(&g_sRxBuf[ucPort], ucChar); } } // if not Telnet, then only write the data once. else #endif { if (fDataDebugFlag) CONSOLE("%u: from UART %02X\n", ucPort, ucChar); if (IsModemModeCommand(ucPort)) ProcessModemModeCommand(ucPort, ucChar); else { ProcessModemModeData(ucPort, ucChar); RingBufWriteOne(&g_sRxBuf[ucPort], ucChar); } ProcessModemToServerData(ucPort); ProcessServerToModemData(ucPort, ucChar); } } } #ifdef SERIAL_FLOW_CONTROL // If flow control is enabled, check the status of the RX buffer to // determine if flow control GPIO needs to be asserted. if(g_sParameters.sPort[ucPort].ucFlowControl == SERIAL_FLOW_CONTROL_HW) { // If the ring buffer is down to less than 25% free, assert the // outbound flow control pin. if(RingBufFree(&g_sRxBuf[ucPort]) < (RingBufSize(&g_sRxBuf[ucPort]) / 4)) { GPIOPinWrite(g_ulFlowOutBase[ucPort], g_ulFlowOutPin[ucPort], g_ulFlowOutPin[ucPort]); } } #endif // See if there is space to be filled in the transmit FIFO. if(((ulStatus & UART_INT_TX) != 0) || (ulStatus == 0)) { bool fInMode = true; // Loop while there is space in the transmit FIFO and characters to be sent. while(!RingBufEmpty(&g_sTxBuf[ucPort]) && UARTSpaceAvail(g_ulUARTBase[ucPort])) { uint8_t ucChar = RingBufReadOne(&g_sTxBuf[ucPort]); if (fDataDebugFlag) CONSOLE("%u: to UART %02X\n", ucPort, ucChar); // Write the next character into the transmit FIFO. UARTCharPut(g_ulUARTBase[ucPort], ucChar); CustomerSettings1_SerialProcessCharacter(ucPort, ucChar); mcwUARTTxOut[ucPort]--; fInMode = false; } if((ulStatus & UART_INT_TX) != 0) { if ((mcwUARTTxOut[ucPort] == 0) && (fInMode)) { InMode(ucPort); } } } }
// *************** GPIO_Clear *************** void GPIO_Clear( GPIO_PORT_T port, GPIO_PIN_T pins ) { GPIOPinWrite( GPIO_PortBase[port], pins, 0 ); }
void setL3(bool on) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, on); }
// *************** GPIO_Toggle *************** void GPIO_Toggle( GPIO_PORT_T port, GPIO_PIN_T pins ) { unsigned char val = GPIOPinRead( GPIO_PortBase[port], pins ); GPIOPinWrite(GPIO_PortBase[port], pins, ~val); }
void setLightsMask(uint8_t bitmask) { GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1 | GPIO_PIN_0, (((bitmask & 2) == 0) ? 0 : 1) | (((bitmask & 1) == 0) ? 0 : 02)); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4, (((bitmask & 8) == 0) ? 0 : 1) | (((bitmask & 4) == 0) ? 0 : 16)); }
//***************************************************************************** // // This is the main application entry function. // //***************************************************************************** int main(void) { volatile uint32_t ui32Loop; uint32_t ui32TxCount; uint32_t ui32RxCount; // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // ROM_FPULazyStackingEnable(); // // Set the clocking to run from the PLL at 50MHz // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Enable the GPIO port that is used for the on-board LED. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Enable the GPIO pins for the LED (PF2 & PF3). // ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3 | GPIO_PIN_2); // // Open UART0 and show the application name on the UART. // ConfigureUART(); UARTprintf("\033[2JTiva C Series USB bulk device example\n"); UARTprintf("---------------------------------\n\n"); // // Not configured initially. // g_bUSBConfigured = false; // // Enable the GPIO peripheral used for USB, and configure the USB // pins. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5); // // Enable the system tick. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND); ROM_SysTickIntEnable(); ROM_SysTickEnable(); // // Tell the user what we are up to. // UARTprintf("Configuring USB\n"); // // Initialize the transmit and receive buffers. // USBBufferInit(&g_sTxBuffer); USBBufferInit(&g_sRxBuffer); // // Set the USB stack mode to Device mode with VBUS monitoring. // USBStackModeSet(0, eUSBModeForceDevice, 0); // // Pass our device information to the USB library and place the device // on the bus. // USBDBulkInit(0, &g_sBulkDevice); // // Wait for initial configuration to complete. // UARTprintf("Waiting for host...\n"); // // Clear our local byte counters. // ui32RxCount = 0; ui32TxCount = 0; // // Main application loop. // while(1) { // // See if any data has been transferred. // if((ui32TxCount != g_ui32TxCount) || (ui32RxCount != g_ui32RxCount)) { // // Has there been any transmit traffic since we last checked? // if(ui32TxCount != g_ui32TxCount) { // // Turn on the Green LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_PIN_3); // // Delay for a bit. // for(ui32Loop = 0; ui32Loop < 150000; ui32Loop++) { } // // Turn off the Green LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0); // // Take a snapshot of the latest transmit count. // ui32TxCount = g_ui32TxCount; } // // Has there been any receive traffic since we last checked? // if(ui32RxCount != g_ui32RxCount) { // // Turn on the Blue LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); // // Delay for a bit. // for(ui32Loop = 0; ui32Loop < 150000; ui32Loop++) { } // // Turn off the Blue LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); // // Take a snapshot of the latest receive count. // ui32RxCount = g_ui32RxCount; } // // Update the display of bytes transferred. // UARTprintf("\rTx: %d Rx: %d", ui32TxCount, ui32RxCount); } } }
void setLights(bool l1, bool l2, bool l3, bool l4) { GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0 | GPIO_PIN_1, (l2) | (l1 << 1)); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4, (l3 >> 2) | (l4 << 1)); }
void GpioOut::on(void) { // Set the pin high GPIOPinWrite(gpio_.port, gpio_.pin, gpio_.pin); }
void cmdTurnOn(void) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4); // Turn on Blue LED }
// Init the OLED display, assuming the RESET pin of the OLED has been wired to GPIO28, pin 18 (P2.2). void Adafruit_Init(void) { volatile unsigned long delay; GPIOPinWrite(GPIOA3_BASE, 0x10, 0); // RESET = RESET_LOW for (delay = 0; delay < 100; delay = delay + 1);// delay minimum 100 ns GPIOPinWrite(GPIOA3_BASE, 0x10, 0x10); // RESET = RESET_HIGH // Initialization Sequence writeCommand(SSD1351_CMD_COMMANDLOCK); // set command lock writeData(0x12); writeCommand(SSD1351_CMD_COMMANDLOCK); // set command lock writeData(0xB1); writeCommand(SSD1351_CMD_DISPLAYOFF); // 0xAE writeCommand(SSD1351_CMD_CLOCKDIV); // 0xB3 writeCommand(0xF1); // 7:4 = Oscillator Frequency, 3:0 = CLK Div Ratio (A[3:0]+1 = 1..16) writeCommand(SSD1351_CMD_MUXRATIO); writeData(127); writeCommand(SSD1351_CMD_SETREMAP); writeData(0x74); writeCommand(SSD1351_CMD_SETCOLUMN); writeData(0x00); writeData(0x7F); writeCommand(SSD1351_CMD_SETROW); writeData(0x00); writeData(0x7F); writeCommand(SSD1351_CMD_STARTLINE); // 0xA1 if (SSD1351HEIGHT == 96) { writeData(96); } else { writeData(0); } writeCommand(SSD1351_CMD_DISPLAYOFFSET); // 0xA2 writeData(0x0); writeCommand(SSD1351_CMD_SETGPIO); writeData(0x00); writeCommand(SSD1351_CMD_FUNCTIONSELECT); writeData(0x01); // internal (diode drop) //writeData(0x01); // external bias // writeCommand(SSSD1351_CMD_SETPHASELENGTH); // writeData(0x32); writeCommand(SSD1351_CMD_PRECHARGE); // 0xB1 writeCommand(0x32); writeCommand(SSD1351_CMD_VCOMH); // 0xBE writeCommand(0x05); writeCommand(SSD1351_CMD_NORMALDISPLAY); // 0xA6 writeCommand(SSD1351_CMD_CONTRASTABC); writeData(0xC8); writeData(0x80); writeData(0xC8); writeCommand(SSD1351_CMD_CONTRASTMASTER); writeData(0x0F); writeCommand(SSD1351_CMD_SETVSL ); writeData(0xA0); writeData(0xB5); writeData(0x55); writeCommand(SSD1351_CMD_PRECHARGE2); writeData(0x01); writeCommand(SSD1351_CMD_DISPLAYON); //--turn on oled panel }
void cmdTurnOff(void) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00); // Turn off Blue LED }
//***************************************************************************** // //! \brief xgpio001 test execute main body. //! //! \return None. // //***************************************************************************** static void xgpio001Execute(void) { unsigned long ulPin, ulPort; unsigned long ulvalue, ulTemp; int i, j; // // GPIOA PIN mode test // xGPIODirModeSet(xGPIO_PORTA_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_IN); ulvalue = xGPIODirModeGet(xGPIO_PORTA_BASE, xGPIO_PIN_0) ; TestAssert((ulvalue == xGPIO_DIR_MODE_IN), "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error"); xGPIODirModeSet(xGPIO_PORTA_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_OUT); ulvalue = xGPIODirModeGet(xGPIO_PORTA_BASE, xGPIO_PIN_0) ; TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error"); xGPIODirModeSet(xGPIO_PORTA_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_IN); ulvalue = xGPIODirModeGet(xGPIO_PORTA_BASE, xGPIO_PIN_4) ; TestAssert((ulvalue == xGPIO_DIR_MODE_IN), "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error"); xGPIODirModeSet(xGPIO_PORTA_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_OUT); ulvalue = xGPIODirModeGet(xGPIO_PORTA_BASE, xGPIO_PIN_4) ; TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error"); // // GPIOB pin mode test // xGPIODirModeSet(xGPIO_PORTB_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_IN); ulvalue = xGPIODirModeGet(xGPIO_PORTB_BASE, xGPIO_PIN_0) ; TestAssert((ulvalue == xGPIO_DIR_MODE_IN), "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error"); xGPIODirModeSet(xGPIO_PORTB_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_OUT); ulvalue = xGPIODirModeGet(xGPIO_PORTB_BASE, xGPIO_PIN_0) ; TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error"); xGPIODirModeSet(xGPIO_PORTB_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_IN); ulvalue = xGPIODirModeGet(xGPIO_PORTB_BASE, xGPIO_PIN_4) ; TestAssert((ulvalue == xGPIO_DIR_MODE_IN), "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error"); xGPIODirModeSet(xGPIO_PORTB_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_OUT); ulvalue = xGPIODirModeGet(xGPIO_PORTB_BASE, xGPIO_PIN_4) ; TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error"); xIntDisable(xINT_GPIOA); xIntDisable(xINT_GPIOB); // // GPIOA int enable test // for(i = 0; i < 5; i++) { xGPIOPinIntEnable(xGPIO_PORTA_BASE, xGPIO_PIN_0, ulIntTypes[i]); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_CFGR0) & EXTI_CFGR0_SRCTYPE_M; TestAssert(ulTemp == ulIntTypes[i], "xgpio, \"xGPIOPinIntEnable \" error"); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_ESSRO) & AFIO_ESSR1_EXTINPIN_B; TestAssert(ulTemp == 0, "xgpio, \"xGPIOPinIntEnable \" error"); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_ICR) & 0x00000001; TestAssert(ulTemp == 0x00000001, "xgpio, \"xGPIOPinIntEnable \" error"); } // // GPIOB int enable test // for(i = 0; i < 5; i++) { xGPIOPinIntEnable(xGPIO_PORTB_BASE, xGPIO_PIN_9, ulIntTypes[i]); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_CFGR0 + 9*4) & EXTI_CFGR0_SRCTYPE_M; TestAssert(ulTemp == ulIntTypes[i], "xgpio, \"xGPIOPinIntEnable \" error"); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_ESSR1) & (AFIO_ESSR1_EXTINPIN_B << 4); TestAssert(ulTemp == (AFIO_ESSR1_EXTINPIN_B << 4), "xgpio, \"xGPIOPinIntEnable \" error"); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_ICR) & (0x00000001 << 9); TestAssert(ulTemp == (0x00000001 << 9), "xgpio, \"xGPIOPinIntEnable \" error"); } // // Int Disable test // for(ulPin = 0; ulPin < 16; ulPin++) { xGPIOPinIntDisable(GPIO_AFIO_BASE, ulPackedPin[ulPin]); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_ICR) & (0x00000001 << ulPin); TestAssert(ulTemp == 0, "xgpio, \"Interrupt disable test \" error"); } // // GPIOA out/in test // xGPIODirModeSet( xGPIO_PORTA_BASE, xGPIO_PIN_0, GPIO_DIR_MODE_OUT ); xGPIOPinWrite(xGPIO_PORTA_BASE, xGPIO_PIN_0, 1); ulTemp = GPIOPinPortDoutGet(xGPIO_PORTA_BASE); TestAssert(ulTemp == xGPIO_PIN_0, "xgpio, \"Output pin value set \" error"); xGPIOPinWrite(xGPIO_PORTA_BASE, xGPIO_PIN_0, 0); ulTemp = GPIOPinPortDoutGet(xGPIO_PORTA_BASE); TestAssert(ulTemp == 0, "xgpio, \"Output pin value set \" error"); // // GPIOB out/in test // xGPIODirModeSet( xGPIO_PORTB_BASE, xGPIO_PIN_2, GPIO_DIR_MODE_OUT ); xGPIOPinWrite(xGPIO_PORTB_BASE, xGPIO_PIN_2, 1); ulTemp = GPIOPinPortDoutGet(xGPIO_PORTB_BASE) & xGPIO_PIN_2; TestAssert(ulTemp == xGPIO_PIN_2, "xgpio, \"Output pin value set \" error"); xGPIOPinWrite(xGPIO_PORTB_BASE, xGPIO_PIN_2, 0); ulTemp = GPIOPinPortDoutGet(xGPIO_PORTB_BASE) & xGPIO_PIN_2; TestAssert(ulTemp == 0, "xgpio, \"Output pin value set \" error"); GPIOPortWrite(xGPIO_PORTB_BASE, 0x00000004); ulTemp = GPIOPinPortDoutGet(xGPIO_PORTB_BASE) & xGPIO_PIN_2; TestAssert(ulTemp == 0x00000004, "xgpio, \"Output port value set \" error"); GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_2, 0); ulTemp = GPIOPinPortDoutGet(xGPIO_PORTB_BASE) & xGPIO_PIN_2; TestAssert(ulTemp == 0, "xgpio, \"Output port value set2 \" error"); // // EXTI line De-bounce enable test // EXTILineDebounceEnable(xGPIO_PIN_0); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_CFGR0) & EXTI_CFGR0_DBEN; TestAssert(ulTemp == EXTI_CFGR0_DBEN, "xgpio, \"De-bounce enable test \" error"); // // EXTI line De-bounce disable test // EXTILineDebounceDisable(xGPIO_PIN_0); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_CFGR0) & EXTI_CFGR0_DBEN; TestAssert(ulTemp == 0, "xgpio, \"De-bounce disable test \" error"); // // EXTI line De-bounce time set test // for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { EXTIDebounceTimeSet(ulEXTILines[i], ulDeBounceTime[j]); ulTemp = EXTIDebounceTimeGet(ulEXTILines[i]); TestAssert(ulTemp == ulDeBounceTime[j], "xgpio, \"De-bounce disable test \" error"); } } // // EXTI Wake Up Int configure test // EXTIWakeUpIntConfigure(ulEXTIWakeUpInt[0]); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPCR) & EXTI_WAKUPCR_EVWUPIEN; TestAssert(ulTemp == EXTI_WAKUPCR_EVWUPIEN, "xgpio, \"EXTI Wake Up Int Enable \" error"); EXTIWakeUpIntConfigure(ulEXTIWakeUpInt[1]); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPCR) & EXTI_WAKUPCR_EVWUPIEN; TestAssert(ulTemp == 0, "xgpio, \"EXTI Wake Up Int Enable \" error"); // // EXTI Wake up Configure test // for(i = 0; i < 3; i++) { EXTILineWakeUpConfigure(ulEXTILines[i], ulEXTIWakeUpLevel[0], ulEXTIWakeUp[0]); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPPOLR) & (1 << ulEXTILineShift[i]); TestAssert(ulTemp == (1 << ulEXTILineShift[i]), "xgpio, \"EXTI Wake Up Level \" error"); EXTILineWakeUpConfigure(ulEXTILines[i], ulEXTIWakeUpLevel[1], ulEXTIWakeUp[0]); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPPOLR) & (1 << ulEXTILineShift[i]); TestAssert(ulTemp == 0, "xgpio, \"EXTI Wake Up Level \" error"); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPCR) & (1 << ulEXTILineShift[i]); TestAssert(ulTemp == (1 << ulEXTILineShift[i]), "xgpio, \"EXTI Wake Up Enable \" error"); EXTILineWakeUpConfigure(ulEXTILines[i], ulEXTIWakeUpLevel[0], ulEXTIWakeUp[1]); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPCR) & (1 << ulEXTILineShift[i]); TestAssert(ulTemp == 0, "xgpio, \"EXTI Wake Up Disable \" error"); } // // GPIO Pad configure // GPIOPadConfigSet(GPIO_PORTA_BASE, xGPIO_PIN_3, ulStrengthValue[0], ulOpenDrain[0] | ulPullResistor[0]); ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_DRVR) & xGPIO_PIN_3; TestAssert(ulTemp ==0, "xgpio, \"Current drain Configure\" error"); ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_PUR) & xGPIO_PIN_3; TestAssert(ulTemp == xGPIO_PIN_3, "xgpio, \"Pull up resistor Enable \" error"); ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_PDR) & xGPIO_PIN_3; TestAssert(ulTemp == 0, "xgpio, \"Pull up resistor Enable \" error"); ulTemp = xHWREG(ulPort + GPIO_ODR) & xGPIO_PIN_3; TestAssert(ulTemp == xGPIO_PIN_3, "xgpio, \"Open drain enable \" error"); GPIOPadConfigSet(GPIO_PORTA_BASE, xGPIO_PIN_3, ulStrengthValue[1], ulOpenDrain[1] | ulPullResistor[1]); ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_DRVR) & xGPIO_PIN_3; TestAssert(ulTemp == xGPIO_PIN_3, "xgpio, \"Current drain Configure\" error"); ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_PUR) & xGPIO_PIN_3; TestAssert(ulTemp == 0, "xgpio, \"Pull up resistor Enable \" error"); ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_PDR) & xGPIO_PIN_3; TestAssert(ulTemp == xGPIO_PIN_3, "xgpio, \"Pull up resistor Enable \" error"); ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_ODR) & xGPIO_PIN_3; TestAssert(ulTemp == 0, "xgpio, \"Open drain disable \" error"); // // Software Trigger test // for(i = 0; i < 3; i++) { EXTILineSoftwareTrigger(ulEXTILines[i]); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_SSCR) & ulEXTILines[i]; TestAssert(ulTemp == ulEXTILines[i], "xgpio, \"Software Trigger Set \" error"); } // // Software Trigger clear // for(i = 0; i < 3; i++) { EXTILineSoftwareClear(ulEXTILines[i]); ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_SSCR) & ulEXTILines[i]; TestAssert(ulTemp == 0, "xgpio, \"Software Trigger Clear \" error"); } // // Short pin to pin test // ulTemp = xGPIOSPinToPin(PA0); TestAssert(ulTemp == ulPinValue[0], "xgpio, \" Short pin to pin test \" error"); ulTemp = xGPIOSPinToPin(PA1); TestAssert(ulTemp == ulPinValue[1], "xgpio, \" Short pin to pin test \" error"); ulTemp = xGPIOSPinToPin(PA2); TestAssert(ulTemp == ulPinValue[2], "xgpio, \" Short pin to pin test \" error"); // // Short pin write test // xGPIOSPinWrite(PA0, 1); ulTemp = GPIOSPinRead(PA0) & GPIO_PIN_0; TestAssert(ulTemp == GPIO_PIN_0, "xgpio, \"Short pin write test \" error"); // // Ture pin to ADC function // xSPinTypeADC(ADC0, PA0); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 0); TestAssert((ulTemp == (1 << 0 )), "xgpio, \"Turn pin to ADC AIN0 \" error"); xSPinTypeADC(ADC1, PA1); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 2); TestAssert((ulTemp == (1 << 2 )), "xgpio, \"Turn pin to ADC AIN1 \" error"); xSPinTypeADC(ADC2, PA2); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 4); TestAssert((ulTemp == (1 << 4 )), "xgpio, \"Turn pin to ADC AIN2 \" error"); xSPinTypeADC(ADC3, PA3); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 6); TestAssert((ulTemp == (1 << 6 )), "xgpio, \"Turn pin to ADC AIN3 \" error"); xSPinTypeADC(ADC4, PA4); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 8); TestAssert((ulTemp == (1 << 8 )), "xgpio, \"Turn pin to ADC AIN4 \" error"); xSPinTypeADC(ADC5, PA5); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 10); TestAssert((ulTemp == (1 << 10 )), "xgpio, \"Turn pin to ADC AIN5 \" error"); xSPinTypeADC(ADC6, PA6); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 12); TestAssert((ulTemp == (1 << 12 )), "xgpio, \"Turn pin to ADC AIN6 \" error"); xSPinTypeADC(ADC7, PA7); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 14); TestAssert((ulTemp == (1 << 14 )), "xgpio, \"Turn pin to ADC AIN7 \" error"); // // Ture pin to I2C function // xSPinTypeI2C(I2C0SDA, PA12); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 24); TestAssert((ulTemp == (1 << 24 )), "xgpio, \"Turn pin to I2C SDA \" error"); xSPinTypeI2C(I2C0SCK, PA11); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 22); TestAssert((ulTemp == (1 << 22 )), "xgpio, \"Turn pin to I2C SCK \" error"); /* // // Turn pin to pwm mode // xSPinTypePWM(PWM0, PC2); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP2; ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT2; TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT2), "xgpio, \"Turn pin to PWM function \" error"); xSPinTypePWM(PWM1, PC3); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP3; ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT3; TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT3), "xgpio, \"Turn pin to PWM function \" error"); xSPinTypePWM(PWM2, PC4); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP4; ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT4; TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT4), "xgpio, \"Turn pin to PWM function \" error"); xSPinTypePWM(PWM3, PC5); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP5; ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT5; TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT5), "xgpio, \"Turn pin to PWM function \" error"); xSPinTypePWM(PWM4, PC6); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP6; ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT6; TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT6), "xgpio, \"Turn pin to PWM function \" error"); xSPinTypePWM(PWM5, PA4); ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP5; ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT5; TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT5), "xgpio, \"Turn pin to PWM function \" error"); */ // // Turn pin to spi function test // xSPinTypeSPI(SPI0CLK, PA6); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 12); TestAssert((ulTemp == (3 << 12)), "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0CLK, PB13); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 26); TestAssert((ulTemp == (1 << 26)), "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0MOSI, PA4); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 8); TestAssert((ulTemp == (3 << 8 )), "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0MOSI, PB15); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 30); TestAssert((ulTemp == (1 << 30 )), "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0MISO, PA5); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 10); TestAssert((ulTemp == (3 << 10 )), "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0MISO, PB14); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 28); TestAssert((ulTemp == (1 << 28 )), "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0CS, PA7); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 14); TestAssert((ulTemp == (3 << 14 )), "xgpio, \"Turn pin to SPI function \" error"); xSPinTypeSPI(SPI0CS, PB12); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 24); TestAssert((ulTemp == (1 << 24)), "xgpio, \"Turn pin to SPI function \" error"); // // Turn pin to timer function test // xSPinTypeTimer(TIMCCP0, PA3); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 6); TestAssert((ulTemp == (3 << 6)), "xgpio, \"Turn pin to TIMER function \" error"); /* xSPinTypeTimer(TIMCCP0, PA15); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 30); TestAssert((ulTemp == (3 << 30)), "xgpio, \"Turn pin to TIMER function \" error"); */ xSPinTypeTimer(TIMCCP1, PA2); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 6); TestAssert((ulTemp == (3 << 6)), "xgpio, \"Turn pin to TIMER function \" error"); /* xSPinTypeTimer(TIMCCP1, PA14); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 28); TestAssert((ulTemp == (3 << 28)), "xgpio, \"Turn pin to TIMER function \" error"); */ xSPinTypeTimer(TIMCCP2, PA1); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 2); TestAssert((ulTemp == (3 << 2)), "xgpio, \"Turn pin to TIMER function \" error"); /* xSPinTypeTimer(TIMCCP2, PA13); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 26); TestAssert((ulTemp == (3 << 26)), "xgpio, \"Turn pin to TIMER function \" error"); */ xSPinTypeTimer(TIMCCP3, PA0); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 0); TestAssert((ulTemp == (3 << 0)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP3, PB11); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 22); TestAssert((ulTemp == (3 << 22)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP4, PB2); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 4); TestAssert((ulTemp == (3 << 4)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP4, PB15); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 30); TestAssert((ulTemp == (3 << 30)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP5, PB3); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 6); TestAssert((ulTemp == (3 << 6)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP5, PB14); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 28); TestAssert((ulTemp == (3 << 28)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP6, PB4); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 8); TestAssert((ulTemp == (3 << 8)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP6, PB13); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 26); TestAssert((ulTemp == (3 << 26)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP7, PB5); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 10); TestAssert((ulTemp == (3 << 10)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(TIMCCP7, PB12); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 30); TestAssert((ulTemp == (3 << 30)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(T0EX, PB10); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 20); TestAssert((ulTemp == (3 << 20)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(T0EX, PB7); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 14); TestAssert((ulTemp == (3 << 14)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(T1EX, PA0); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 0); TestAssert((ulTemp == (2 << 0)), "xgpio, \"Turn pin to TIMER function \" error"); xSPinTypeTimer(T1EX, PB6); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 12); TestAssert((ulTemp == (3 << 12)), "xgpio, \"Turn pin to TIMER function \" error"); // // Turn pin to uart function test // xSPinTypeUART(UART0RX, PA8); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 16); TestAssert((ulTemp == (2 << 16)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0TX, PA9); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 18); TestAssert((ulTemp == (2 << 18)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0RTS, PA6); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 12); TestAssert((ulTemp == (2 << 12)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0RTS, PB4); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 8); TestAssert((ulTemp == (2 << 8)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0CTS, PA7); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 14); TestAssert((ulTemp == (2 << 14)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0CTS, PB7); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 14); TestAssert((ulTemp == (2 << 14)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0DCD, PA2); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 4); TestAssert((ulTemp == (2 << 4)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0DCD, PB12); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 24); TestAssert((ulTemp == (2 << 24)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0DSR, PA3); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 6); TestAssert((ulTemp == (2 << 6)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0DSR, PB13); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 26); TestAssert((ulTemp == (2 << 26)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0DTR, PA4); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 8); TestAssert((ulTemp == (2 << 8)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0DTR, PB14); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 28); TestAssert((ulTemp == (2 << 28)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0RI, PA5); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 10); TestAssert((ulTemp == (2 << 10)), "xgpio, \"Turn pin to UART function \" error"); xSPinTypeUART(UART0RI, PB15); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 30); TestAssert((ulTemp == (2 << 30)), "xgpio, \"Turn pin to UART function \" error"); // // Turn the pin to ACMP function // xSPinTypeACMP(CMP0P, PB3); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 6); TestAssert((ulTemp == (1 << 6)), "xgpio, \"Turn pin to ACMP function \" error"); xSPinTypeACMP(CMP0N, PB2); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 4); TestAssert((ulTemp == (1 << 4)), "xgpio, \"Turn pin to ACMP function \" error"); xSPinTypeACMP(CMP0O, PB4); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 8); TestAssert((ulTemp == (1 << 8)), "xgpio, \"Turn pin to ACMP function \" error"); xSPinTypeACMP(CMP1P, PB6); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 12); TestAssert((ulTemp == (1 << 12)), "xgpio, \"Turn pin to ACMP function \" error"); xSPinTypeACMP(CMP1N, PB5); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 10); TestAssert((ulTemp == (1 << 10)), "xgpio, \"Turn pin to ACMP function \" error"); xSPinTypeACMP(CMP1O, PB7); ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 14); TestAssert((ulTemp == (1 << 14)), "xgpio, \"Turn pin to ACMP function \" error"); // // // //xGPIOSPinTypeGPIOInput(PA0); xGPIOSPinWrite(PA0, 1); xGPIOSPinDirModeSet(PA0, xGPIO_DIR_MODE_IN); }
void leds_init() { GPIOPinTypeGPIOOutput(BSP_LED_BASE, BSP_LED_ALL); GPIOPinWrite(BSP_LED_BASE, BSP_LED_ALL, 0); }
//***************************************************************************** // // This is the main loop for the application. // //***************************************************************************** int main(void) { int iIdx; // // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V. This is // a workaround to allow the PLL to operate reliably. // if(REVISION_IS_A2) { SysCtlLDOSet(SYSCTL_LDO_2_75V); } // // Set the clocking to run directly from the PLL at 50MHz. // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // // Initialize the OLED display. // RIT128x96x4Init(1000000); // // Configure CAN 0 Pins. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); GPIOPinTypeCAN(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Configure LED pin. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0); // // Turn off the LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0); // // Enable the CAN controller. // SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0); // // Reset the state of all the message object and the state of the CAN // module to a known state. // CANInit(CAN0_BASE); // // Configure the bit rate for the CAN device, the clock rate to the CAN // controller is fixed at 8MHz for this class of device and the bit rate is // set to CAN_BITRATE. // CANBitRateSet(CAN0_BASE, 8000000, CAN_BITRATE); // // Take the CAN0 device out of INIT state. // CANEnable(CAN0_BASE); // // Hello! // RIT128x96x4StringDraw("CAN FIFO Loopback", 14, 24, 15); // // Enable interrupts from CAN controller. // CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR); // // Enable interrupts for the CAN in the NVIC. // IntEnable(INT_CAN0); // // Enable processor interrupts. // IntMasterEnable(); // // Set the initial state to idle. // g_sCAN.eState = CAN_IDLE; // // Initialize the CAN FIFO buffer. // for(iIdx = 0; iIdx < CAN_FIFO_SIZE; iIdx++) { g_sCAN.pucBufferTx[iIdx] = iIdx + 0x1; } // // Reset the buffer pointer. // g_sCAN.MsgObjectRx.pucMsgData = g_sCAN.pucBufferRx; // // Set the total number of bytes expected. // g_sCAN.ulBytesRemaining = CAN_FIFO_SIZE; // // Configure the receive message FIFO. // CANReceiveFIFO(g_sCAN.pucBufferRx, CAN_FIFO_SIZE); // // Initialized the LED toggle count. // g_ulLEDCount = 0; // // Loop forever. // while(1) { switch(g_sCAN.eState) { case CAN_IDLE: { // // Switch to sending state. // g_sCAN.eState = CAN_SENDING; // // Initialize the transmit count to zero. // g_sCAN.ulBytesTransmitted = 0; // // Schedule all of the CAN transmissions. // CANTransmitFIFO(g_sCAN.pucBufferTx, CAN_FIFO_SIZE); break; } case CAN_SENDING: { // // Wait for all bytes to go out. // if(g_sCAN.ulBytesTransmitted == CAN_FIFO_SIZE) { // // Switch to wait for RX state. // g_sCAN.eState = CAN_WAIT_RX; } break; } case CAN_WAIT_RX: { // // Wait for all new data to be received. // if(g_sCAN.ulBytesRemaining == 0) { // // Switch to wait for Process data state. // g_sCAN.eState = CAN_PROCESS; // // Reset the buffer pointer. // g_sCAN.MsgObjectRx.pucMsgData = g_sCAN.pucBufferRx; // // Reset the number of bytes expected. // g_sCAN.ulBytesRemaining = CAN_FIFO_SIZE; } break; } case CAN_PROCESS: { // // Compare the received data to the data that was sent out. // for(iIdx = 0; iIdx < CAN_FIFO_SIZE; iIdx++) { if(g_sCAN.pucBufferTx[iIdx] != g_sCAN.pucBufferRx[iIdx]) { // // Detected an Error Condition. // RIT128x96x4StringDraw("Error ", 14, 34, 15); break; } } // // Change the CAN FIFO data. // for(iIdx = 0; iIdx < CAN_FIFO_SIZE; iIdx++) { // // Increment the data to change it. // g_sCAN.pucBufferTx[iIdx] += 0xB; } // // Handle the LED toggle. // ToggleLED(); // // Return to the idle state. // g_sCAN.eState = CAN_IDLE; break; } default: { break; } } } }
// *************** GPIO_Set *************** void GPIO_Set( GPIO_PORT_T port, GPIO_PIN_T pins ) { GPIOPinWrite(GPIO_PortBase[port], pins, pins); }
void Sensor1OutOn(void) {GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_PIN_5);}
void heart_beat_led(void) { if(GPIOPinRead(LED_OP_BASE, LED_OP_PIN)>>5) GPIOPinWrite(LED_OP_BASE, LED_OP_PIN, OFF); else GPIOPinWrite(LED_OP_BASE, LED_OP_PIN, ON);