Exemplo n.º 1
0
void Lcd_Reset(void)
{
    LCD_RST_CLR;
    xSysCtlDelay(xSysCtlClockGet()/20);
    LCD_RST_SET;
    xSysCtlDelay(xSysCtlClockGet()/20);
}
Exemplo n.º 2
0
int main() {

	//
	// Disable the watchdog
	//
	WDTimerDisable();

	xSysCtlClockSet32KhzFLLExt(); //48mhz from 32768khz external clock

	xSysTickPeriodSet(xSysCtlClockGet()/SYSTICKS_PER_SECOND); //1ms
	xSysTickIntEnable();
	xSysTickEnable(); // End of SysTick init
	ulClockMS = xSysCtlClockGet() / (3 * 1000);

	pwmInit();

	// Setup and configure rf radio
	RF24 radio = RF24();
	rf24_init(radio);

	while (1) {

		// if there is data ready
		report_t gamepad_report;
		if (!getNRF24report(&radio, &gamepad_report))
		{

			drive(&gamepad_report);

			//			if (gamepad_report.reportid == 1) {
			//				// Delay just a little bit to let the other unit
			//				// make the transition to receiver
			//				xSysCtlDelay(ulClockMS * 10);
			//
			//				radio.stopListening();
			//				uint8_t response = 0;
			//				radio.write(&response, sizeof(uint8_t));
			//				radio.startListening();
			//			}


			timeoutcounter = millis();

		} else {
			if ((millis() - timeoutcounter) > TIMEOUT) {
				stopall();
				xSysCtlDelay(ulClockMS * 10);
			}
		}
	}

	return 0;
}
Exemplo n.º 3
0
//////////////////////////////////////////////////////////////////////////////
// Platform (STM32F103X) initialization for peripherals as GPIO, SPI, UARTs //
//////////////////////////////////////////////////////////////////////////////
void platform_init(void)
{
    xSysCtlClockSet(72000000,  xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);

    xSysCtlDelay((xSysCtlClockGet()/1000)*50); // wait 50ms


    /**************************/
    /* GPIO_A For SPI CS PIN  */// It must be first to enable GPIO peripheral than other peripheral. (Otherwise, UART do not run in STM32F103X)
    /**************************/
    xSysCtlPeripheralEnable( xSYSCTL_PERIPH_GPIOA );
    xGPIODirModeSet(xGPIO_PORTA_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_OUT);


    /************/
    /* For UART */
    /************/
    xSysCtlPeripheralReset(xSYSCTL_PERIPH_UART1);
    xSysCtlPeripheralEnable(xSYSCTL_PERIPH_UART1);
    xSPinTypeUART(UART1TX,PA9);
    xSPinTypeUART(UART1RX,PA10);
    xUARTConfigSet(xUART1_BASE, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
    xUARTEnable(xUART1_BASE, (UART_BLOCK_UART | UART_BLOCK_TX | UART_BLOCK_RX));


    /***********/
    /* For SPI */
    /***********/
    xSysCtlPeripheralReset(WIZCHIP_SPI_PERIPH);
    xSysCtlPeripheralEnable(WIZCHIP_SPI_PERIPH);
    xSPinTypeSPI(WIZCHIP_SPI_CLK, WIZCHIP_SPI_CLK_PIN);  // xGPIODirModeSet(xGPIO_PORTA, xGPIO_PIN_5, GPIO_TYPE_AFOUT_STD, GPIO_OUT_SPEED_50M);
    xSPinTypeSPI(WIZCHIP_SPI_MOSI,WIZCHIP_SPI_MOSI_PIN);  // xGPIODirModeSet(xGPIO_PORTA, xGPIO_PIN_7, GPIO_TYPE_AFOUT_STD, GPIO_OUT_SPEED_50M);
    xSPinTypeSPI(WIZCHIP_SPI_MISO,WIZCHIP_SPI_MISO_PIN);  // xGPIODirModeSet(xGPIO_PORTA, xGPIO_PIN_6, GPIO_TYPE_IN_FLOATING, GPIO_IN_SPEED_FIXED);
    xSPIConfigSet(WIZCHIP_SPI_BASE, xSysCtlClockGet()/2, xSPI_MOTO_FORMAT_MODE_0 | xSPI_MODE_MASTER | xSPI_MSB_FIRST | xSPI_DATA_WIDTH8);

    xSPISSSet(WIZCHIP_SPI_BASE, SPI_SS_SOFTWARE, xSPI_SS_NONE);
    xSPIEnable(WIZCHIP_SPI_BASE);

    printf("HCLK = %dMHz\r\n", (unsigned int)(xSysCtlClockGet()/1000000));
}
Exemplo n.º 4
0
static void xsysctl_SetHCLK_test(void)
{
	unsigned long ulTemp;

    ulTemp = xSysCtlClockGet();
    TestAssert((ulTemp == 72000000), "xsysctl API error!");

//    xSysCtlClockSet(32000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
//    ulTemp = xSysCtlClockGet();
//    TestAssert((ulTemp == 32000000), "xsysctl API error!");
/*
    xSysCtlClockSet(24000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
    ulTemp = xSysCtlClockGet();
    TestAssert((ulTemp == 24000000), "xsysctl API error!");

    xSysCtlClockSet(16000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
    ulTemp = xSysCtlClockGet();
    TestAssert((ulTemp == 16000000), "xsysctl API error!");

    xSysCtlClockSet(8000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
    ulTemp = xSysCtlClockGet();
    TestAssert((ulTemp == 8000000), "xsysctl API error!");

    xSysCtlClockSet(4000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
    ulTemp = xSysCtlClockGet();
    TestAssert((ulTemp == 4000000), "xsysctl API error!");

    xSysCtlClockSet(2000000, xSYSCTL_OSC_INT | xSYSCTL_XTAL_8MHZ);
    ulTemp = xSysCtlClockGet();
    TestAssert((ulTemp == 2000000), "xsysctl API error!");

    xSysCtlClockSet(72000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
    ulTemp = xSysCtlClockGet();
    TestAssert((ulTemp == 72000000), "xsysctl API error!");
*/
}
Exemplo n.º 5
0
void Lcd_Init(void)
{
    LCD_GPIO_Init();
    Lcd_Reset();
    
    Lcd_WriteIndex(0x11);//Sleep exit 
    xSysCtlDelay(xSysCtlClockGet()/10);
    
    //ST7735R Frame Rate
    Lcd_WriteIndex(0xB1); 
    Lcd_WriteData(0x01); Lcd_WriteData(0x2C); Lcd_WriteData(0x2D); 
    Lcd_WriteIndex(0xB2); 
    Lcd_WriteData(0x01); Lcd_WriteData(0x2C); Lcd_WriteData(0x2D); 
    Lcd_WriteIndex(0xB3); 
    Lcd_WriteData(0x01); Lcd_WriteData(0x2C); Lcd_WriteData(0x2D); 
    Lcd_WriteData(0x01); Lcd_WriteData(0x2C); Lcd_WriteData(0x2D); 
    
    Lcd_WriteIndex(0xB4); //Column inversion 
    Lcd_WriteData(0x07); 
    
    //ST7735R Power Sequence
    Lcd_WriteIndex(0xC0); 
    Lcd_WriteData(0xA2); Lcd_WriteData(0x02); Lcd_WriteData(0x84); 
    Lcd_WriteIndex(0xC1); Lcd_WriteData(0xC5); 
    Lcd_WriteIndex(0xC2); 
    Lcd_WriteData(0x0A); Lcd_WriteData(0x00); 
    Lcd_WriteIndex(0xC3); 
    Lcd_WriteData(0x8A); Lcd_WriteData(0x2A); 
    Lcd_WriteIndex(0xC4); 
    Lcd_WriteData(0x8A); Lcd_WriteData(0xEE); 
    
    Lcd_WriteIndex(0xC5); //VCOM 
    Lcd_WriteData(0x0E); 
    
    Lcd_WriteIndex(0x36); //MX, MY, RGB mode 
    Lcd_WriteData(0xC8); 
    
    //ST7735R Gamma Sequence
    Lcd_WriteIndex(0xe0); 
    Lcd_WriteData(0x0f); Lcd_WriteData(0x1a); 
    Lcd_WriteData(0x0f); Lcd_WriteData(0x18); 
    Lcd_WriteData(0x2f); Lcd_WriteData(0x28); 
    Lcd_WriteData(0x20); Lcd_WriteData(0x22); 
    Lcd_WriteData(0x1f); Lcd_WriteData(0x1b); 
    Lcd_WriteData(0x23); Lcd_WriteData(0x37); Lcd_WriteData(0x00); 
    
    Lcd_WriteData(0x07); 
    Lcd_WriteData(0x02); Lcd_WriteData(0x10); 
    Lcd_WriteIndex(0xe1); 
    Lcd_WriteData(0x0f); Lcd_WriteData(0x1b); 
    Lcd_WriteData(0x0f); Lcd_WriteData(0x17); 
    Lcd_WriteData(0x33); Lcd_WriteData(0x2c); 
    Lcd_WriteData(0x29); Lcd_WriteData(0x2e); 
    Lcd_WriteData(0x30); Lcd_WriteData(0x30); 
    Lcd_WriteData(0x39); Lcd_WriteData(0x3f); 
    Lcd_WriteData(0x00); Lcd_WriteData(0x07); 
    Lcd_WriteData(0x03); Lcd_WriteData(0x10);  
    
    Lcd_WriteIndex(0x2a);
    Lcd_WriteData(0x00);Lcd_WriteData(0x00);
    Lcd_WriteData(0x00);Lcd_WriteData(0x7f);
    Lcd_WriteIndex(0x2b);
    Lcd_WriteData(0x00);Lcd_WriteData(0x00);
    Lcd_WriteData(0x00);Lcd_WriteData(0x9f);
    
    Lcd_WriteIndex(0xF0); //Enable test command  
    Lcd_WriteData(0x01); 
    Lcd_WriteIndex(0xF6); //Disable ram power save mode 
    Lcd_WriteData(0x00); 
    
    Lcd_WriteIndex(0x3A); //65k mode 
    Lcd_WriteData(0x05);    
    
    Lcd_WriteIndex(0x29);//Display on
}
Exemplo n.º 6
0
//*****************************************************************************
//
//! \brief 001 test execute main body.
//!
//! \return None.
//
//*****************************************************************************
static void Test001Execute(void)
{
    int i , j;
	  
	  SPLC780SetBacklight(SPLC780_BL_CLOSE);
	  SPLC780SetBacklight(SPLC780_BL_OPEN);
	  SPLC780SetBacklight(SPLC780_BL_CLOSE);
	  SPLC780SetBacklight(SPLC780_BL_OPEN);
    
    //
    // Location Set & Display string, number Test
    //
    SPLC780LocationSet(0, 0);
    SPLC780DisplayString("Hello SPLC780!");
    SPLC780LocationSet(0, 1);
    SPLC780DisplayString("Number:");
    SPLC780DisplayN(10086);
    xSysCtlDelay(xSysCtlClockGet() / 4);
    SPLC780LocationSet(0,1);
    SPLC780DisplayString("Display off/on");
    xSysCtlDelay(xSysCtlClockGet() / 4);
    SPLC780DisplayOff();    
    xSysCtlDelay(xSysCtlClockGet() / 4 );
    SPLC780DisplayOn();
    xSysCtlDelay(xSysCtlClockGet() / 4);
    //
    // Cursor style
    //
    SPLC780DisplayClear();
    SPLC780DisplayString("Cursor Test");
    SPLC780CursorOn(xfalse);
    xSysCtlDelay(xSysCtlClockGet() / 4);
    SPLC780CursorOff();
    xSysCtlDelay(xSysCtlClockGet() / 4);
    
    //
    // Cursor will blink at the end of line
    //
    SPLC780CursorOn(xtrue);
    SPLC780CursorRightMove(1);
    xSysCtlDelay(xSysCtlClockGet() / 4);
    SPLC780CursorRightMove(5);
    xSysCtlDelay(xSysCtlClockGet() / 4);
    SPLC780CursorLeftMove(4);
    xSysCtlDelay(xSysCtlClockGet() / 4);
    
    for(i = 0; i < 10; i++)
    {
        SPLC780CursorRightMove(1);
        xSysCtlDelay(xSysCtlClockGet() / 10);     
    }
    
    for(i = 0; i < 10; i++)
    {
        SPLC780CursorLeftMove(1);
        xSysCtlDelay(xSysCtlClockGet() / 10);     
    }    

    SPLC780LocationSet(0, 1);
    SPLC780DisplayString("Cursor Home");
    xSysCtlDelay(xSysCtlClockGet() / 4);
    
    SPLC780Home();
    
    //
    // Display Right shift
    //
    SPLC780DisplayClear();
    SPLC780DisplayString("Right scrolling string");
    SPLC780LocationSet(0, 1);
    SPLC780DisplayString("        Line 2         ");
    for(i = 0; i < 20; i++)
    {
        SPLC780DisplayRightShift(1);
        xSysCtlDelay(xSysCtlClockGet() / 10);
    }
    
    //
    // Display Left shift
    //
    SPLC780DisplayClear();
    SPLC780DisplayString("Left scrolling string");
    SPLC780LocationSet(0, 1);
    SPLC780DisplayString("        Line 2         ");
    for(i = 0; i < 20; i++)
    {
        SPLC780DisplayLeftShift(1);
        xSysCtlDelay(xSysCtlClockGet() / 10);
    }
    
    //
    // Display Right Left shift    
    //
    SPLC780DisplayClear();
    SPLC780DisplayString("Left Right scrolling string");
    SPLC780LocationSet(0, 1);
    SPLC780DisplayString("        Line 2         ");    
    for(j = 0; j < 2; j++)
    {  
        for(i = 0; i < 10; i++)
        {
            SPLC780DisplayRightShift(1);
            xSysCtlDelay(xSysCtlClockGet() / 10);
        }
        for(i = 0; i < 10; i++)
        {
            SPLC780DisplayLeftShift(1);
            xSysCtlDelay(xSysCtlClockGet() / 10);
        } 
    }
    SPLC780Home();
    xSysCtlDelay(xSysCtlClockGet() / 4);
    
    //
    // Cursor Move Direction
    //
    SPLC780DisplayClear();
    SPLC780LocationSet(10, 1);
    xSysCtlDelay(xSysCtlClockGet() / 4);
    SPLC780EntryModeSet(SPLC780_MOVE_DIRECTION_DEC, xfalse);
    SPLC780DisplayString("DEC");
    
    SPLC780LocationSet(10, 2);
    xSysCtlDelay(xSysCtlClockGet() / 4);
    SPLC780EntryModeSet(SPLC780_MOVE_DIRECTION_DEC, xtrue);
    SPLC780DisplayString("DEC shift");
    
    SPLC780DisplayClear();
    SPLC780LocationSet(10, 1);
    xSysCtlDelay(xSysCtlClockGet() / 4);
    SPLC780EntryModeSet(SPLC780_MOVE_DIRECTION_INC, xfalse);
    SPLC780DisplayString("INC");
    
    SPLC780LocationSet(10, 2);
    xSysCtlDelay(xSysCtlClockGet() / 4);
    SPLC780EntryModeSet(SPLC780_MOVE_DIRECTION_INC, xtrue);
    SPLC780DisplayString("INC shift");
    xSysCtlDelay(xSysCtlClockGet() / 4);
    
    SPLC780DisplayClear();
    SPLC780EntryModeSet(SPLC780_MOVE_DIRECTION_INC, xfalse);
    SPLC780DisplayString("Complete");
}
Exemplo n.º 7
0
//*****************************************************************************
//
//! \brief xsysctl 001 test of set and get HCLK test .
//!
//! \return None.
//
//*****************************************************************************
static void xsysctl_SetHCLK_test(void)
{
    unsigned long ulTemp,i;
    for(i=0;i<16;i++)
    {
        SysCtlHClockSet((i<<24)|SYSCTL_XTAL_12MHZ|
                           SYSCTL_OSC_MAIN|SYSCTL_PLL_PWRDN|SYSCTL_INT_OSC_DIS);
        ulTemp = SysCtlHClockGet();
        TestAssert(ulTemp == 12000000/(i+1), "xsysctl API error!");
    }
    
    for (i=0;i<16;i++)
    {
        SysCtlHClockSet((i<<24)|SYSCTL_XTAL_12MHZ|
                                               SYSCTL_OSC_INT|SYSCTL_PLL_PWRDN);
        ulTemp = SysCtlHClockGet();
        TestAssert(ulTemp == 22000000/(i+1), "xsysctl API error!");
    }

    for(i=0;i<16;i++)
    {
        SysCtlHClockSet((i<<24)|SYSCTL_XTAL_12MHZ|
                                                SYSCTL_OSC_PLL|SYSCTL_PLL_MAIN);
        ulTemp = SysCtlHClockGet();
        TestAssert(ulTemp == 48000000/(i+1), "xsysctl API error!");
    }

    for(i=0;i<16;i++)
    {
        SysCtlHClockSet((i<<24)|SYSCTL_XTAL_12MHZ|
                                                 SYSCTL_OSC_PLL|SYSCTL_PLL_INT);
        ulTemp = SysCtlHClockGet();
        TestAssert(ulTemp == 48000000/(i+1), "xsysctl API error!");
    }

    //
    // Clock Set Test Source from Extern_12MHz
    //
    for(i=0;i<19;i++)
    {   
        unsigned long ulTempClk;
        ulTempClk = 1000000*ulSYSCTL_CLKSET[i];
        xSysCtlClockSet(ulTempClk, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_12MHZ);
        ulTemp = xSysCtlClockGet();
        TestAssert(ulTemp == ulTempClk,"xsysctl API error!");
    }

    //
    // Clock Set Test Source from Inter_10KHz
    //
    xSysCtlClockSet(10000, xSYSCTL_OSC_INTSL|xSYSCTL_INTSL_10KHZ);
    ulTemp = xSysCtlClockGet();
    TestAssert(ulTemp == 10000, "xsysctl API error!");
    
    //
    // Clock Set Test Source from Inter_22MHz
    //
    xSysCtlClockSet(22000000, xSYSCTL_OSC_INT|xSYSCTL_INT_22MHZ);
    ulTemp = xSysCtlClockGet();
    TestAssert(ulTemp == 22000000,"xsysctl API error!");
    
    //
    // Clock Set Test Source from Inter_32KHz
    //
    xSysCtlClockSet(32768, xSYSCTL_OSC_EXTSL|xSYSCTL_XTALSL_32768HZ);
    ulTemp = SysCtlHClockGet();
    TestAssert(ulTemp == 32000, "xsysctl API error!");

}