Exemplo n.º 1
0
//*****************************************************************************
//		GLOBAL DATA VARIABLES
//*****************************************************************************
int main(void)
{
	//
		// 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.
		//
		FPULazyStackingEnable();

		//
		// Set the clocking to run directly from the crystal.
		//
		SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ);

		//
		// Set up and enable the SysTick timer.  It will be used as a reference
		// for delay loops in the interrupt handlers.  The SysTick timer period
		// will be set up for one second.
		//
		SysTickPeriodSet(SysCtlClockGet());
		SysTickEnable();

		GPIO_Initialize();

	while(1)
	{
		LED_ChangeColor(LED_BLUE);
		DelayMS(1);
		LED_ChangeColor(LED_RED);
		DelayMS(1);
	}

}
//*****************************************************************************
//
//	Initializes the hardware's system clock and the SysTick Interrupt
//
//*****************************************************************************
void SysTickInit() {
    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

	//
	// Get the system clock speed.
	//
	systemClock = SysCtlClockGet();

    //
    // Configure SysTick interrupts
    //
    SysTickPeriodSet(systemClock / SYSTICK_FREQUENCY);
    SysTickIntEnable();
    SysTickEnable();
	
    //
	// 	Code to cause a wait for a "Select Button" press
    //
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
	GPIOPinTypeGPIOInput(GPIO_PORTG_BASE, GPIO_PIN_7);
	RIT128x96x4Init(1000000);
	RIT128x96x4StringDraw("Press \"Select\" Button", 0, 24, 15);
	RIT128x96x4StringDraw("To Continue", 32, 32, 15);
	while(GPIOPinRead(GPIO_PORTG_BASE, GPIO_PIN_7));
	SysCtlPeripheralDisable(SYSCTL_PERIPH_GPIOG);
	SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOG);

}
Exemplo n.º 3
0
int ConnectNetwork(Network* n, char* addr, int port)
{
	SlSockAddrIn_t sAddr;
	int addrSize;
	int retVal;
	unsigned long ipAddress;

	sl_NetAppDnsGetHostByName(addr, strlen(addr), &ipAddress, AF_INET);

	sAddr.sin_family = AF_INET;
	sAddr.sin_port = sl_Htons((unsigned short)port);
	sAddr.sin_addr.s_addr = sl_Htonl(ipAddress);

	addrSize = sizeof(SlSockAddrIn_t);

	n->my_socket = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
	if( n->my_socket < 0 ) {
		// error
		return -1;
	}

	retVal = sl_Connect(n->my_socket, ( SlSockAddr_t *)&sAddr, addrSize);
	if( retVal < 0 ) {
		// error
		sl_Close(n->my_socket);
	    return retVal;
	}

	SysTickIntRegister(SysTickIntHandler);
	SysTickPeriodSet(80000);
	SysTickEnable();

	return retVal;
}
Exemplo n.º 4
0
Arquivo: main.c Projeto: saiyn/OSAL
static void hal_init(void)
{
	 gSysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); 
	 //gSysClock = SysCtlClockFreqSet((SYSCTL_OSC_INT | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_320), 120000000);
	
	 //SysCtlDeepSleep();
	
	 /*systick = 1ms*/
	 SysTickPeriodSet(gSysClock / 1000);
   SysTickEnable();
   SysTickIntEnable();
	
	 bsp_gpio_init();
	 uart_hal_init();
	
	 bsp_adc_init();
	 bsp_spi0_init();
	 bsp_timer0_init();
	 bsp_timer1_init();
	 bsp_bt_uart_init();
	 bsp_nad_app_uart_init();
   
	 //bsp_pwm1_init();
	 IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRIORITY);
	 IntMasterEnable();
}
Exemplo n.º 5
0
Arquivo: main.c Projeto: gluker/sonar
void hw_init(void){
	SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

	f_cpu = SysCtlClockGet();
	SysTickPeriodSet(0xffffffff);
	SysTickEnable();
//	UARTStdioInit();

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	GPIODirModeSet(SONAR_PORT, TRIG_PIN, GPIO_DIR_MODE_OUT);
	GPIODirModeSet(SONAR_PORT, SERVO_PIN, GPIO_DIR_MODE_OUT);

	GPIOPinTypeGPIOInput(SONAR_PORT, ECHO_PIN);
	GPIOIntTypeSet(SONAR_PORT, ECHO_PIN, GPIO_RISING_EDGE);
	GPIOPinIntEnable(SONAR_PORT,ECHO_PIN);
	IntEnable(INT_GPIOD);

	//Timer configuration
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	TimerConfigure(TIMER0_BASE, TIMER_CFG_A_PERIODIC);
	const long timer_match = (f_cpu/1000000)*10;
	const long timer_out = (f_cpu/1000)*80;
	TimerLoadSet(TIMER0_BASE, TIMER_A, timer_out);
	TimerMatchSet(TIMER0_BASE, TIMER_A, timer_match);
	TimerEnable(TIMER0_BASE, TIMER_A);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntClear(TIMER0_BASE,TIMER_A);
	IntEnable(INT_TIMER0A);

	IntMasterEnable();

}
Exemplo n.º 6
0
void Board::init() // initialize the board specifics
{
	//
	// 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.
	//
	FPUEnable();
	FPULazyStackingEnable();
	//
	// Set the clocking to run from the PLL at 50MHz
	//
	ROM_SysCtlClockSet(
	SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
	IntMasterEnable(); // Enable interrupts to the processor.
	// Set up the period for the SysTick timer for 1 mS.
	SysTickPeriodSet(SysCtlClockGet() / 1000);
	SysTickIntEnable(); // Enable the SysTick Interrupt.
	SysTickEnable(); // Enable SysTick.
	/*	//
	 // 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.
	 FPUEnable();
	 FPULazyStackingEnable();
	 SysCtlClockSet(
	 SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN
	 | SYSCTL_XTAL_16MHZ); // Set the clocking to run directly from the crystal.
	 IntMasterEnable(); // Enable interrupts to the processor.*/

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Enable the GPIO port that is used for the on-board LED.
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); // Enable the GPIO pins for the LED (PF2).
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);

	/*	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // Enable the peripherals used by this example.
	 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	 IntMasterEnable(); // Enable processor interrupts.
	 // Set up the period for the SysTick timer for 1 mS.
	 SysTickPeriodSet(SysCtlClockGet() / 1000);
	 SysTickIntEnable(); // Enable the SysTick Interrupt.
	 SysTickEnable(); // Enable SysTick.

	 GPIOPinConfigure(GPIO_PA0_U0RX); // Set GPIO A0 and A1 as UART pins.
	 GPIOPinConfigure(GPIO_PA1_U0TX);
	 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)); // Configure the UART for 115,200, 8-N-1 operation.
	 IntEnable(INT_UART0);
	 UARTFIFODisable(UART0_BASE);
	 //	UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8);
	 UARTFlowControlSet(UART0_BASE, UART_FLOWCONTROL_NONE);
	 UARTIntDisable(UART0_BASE, UART_INT_RT);
	 UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_TX); // Enable the UART interrupt.*/
	Board::setLedOn(Board::LED_GREEN, false);
	Board::setLedOn(Board::LED_RED, false);
	Board::setLedOn(Board::LED_BLUE, false);
	AdcInit();
}
Exemplo n.º 7
0
/**
 * This function will initial LM3S board.
 */
void rt_hw_board_init()
{
	
    //
    // 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.
    //
    FPULazyStackingEnable();
    
	// set sysclock to 80M
    SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

	/* init systick */
	SysTickDisable();
	SysTickPeriodSet(SysCtlClockGet()/RT_TICK_PER_SECOND);
	SysTickIntEnable();
	SysTickEnable();

	/* enable ssio */
	//SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);

#if LM3S_EXT_SRAM == 1
	/* init SDRAM */
	rt_hw_sdram_init();
#endif
	/* init console */
	rt_hw_console_init();

	/* enable interrupt */
	IntMasterEnable();
}
Exemplo n.º 8
0
void systick_init(void) {
    // 1 ms period
    SysTickPeriodSet(8000);
    SysTickIntEnable();
    SysTickIntRegister(schedule);
    SysTickEnable();
}
Exemplo n.º 9
0
// **********************************************
// Initializes the real-time clock (systick).
void mRTCInit(unsigned short rtc_rate_given)
{
	g_uiRTCRateHz = rtc_rate_given;
	clockInit();
	SysTickPeriodSet(SysCtlClockGet() / g_uiRTCRateHz);
	//SysTickPeriodSet((SysTickPeriodGet()/4294967296) / (SYSTICK_RATE));

	//
	// Reset real time clock
	g_ullRTCTicks = 0;

	//
	// Register the interrupt handler
	SysTickIntRegister(SysTickISR);
	//
	// Enable interrupt and device
	SysTickIntEnable();
	SysTickEnable();

	// clear the systick() task list.
	short i = 0;
	g_RTCNumTasks = 0;
	for (i = 0; i < SYSTICK_TASK_LIST_SIZE; i++)
	{
		g_RTCTaskList[i] = 0;
	}
}
Exemplo n.º 10
0
//*****************************************************************************
//
// 板级开发包初始化
//
//*****************************************************************************
void BSP_init(void)
{
    // Set the clocking to run directly from the crystal.
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_8MHZ);

    // Enable processor interrupts.
    IntMasterEnable();

    // Configure SysTick for a periodic interrupt.
    SysTickPeriodSet(SysCtlClockGet() / SYSTICKHZ);
    SysTickEnable();
    SysTickIntEnable();

    // Initialize the DEBUG UART.           (UART0)
    DEBUG_UART_init();

    // Initialize the IO Hardware.          (LED/SOL/I2C_HOTSWAP)
    IO_init();

    // Initialize the UART Hardware.        (ICMB/SOL)
    UART_init();

    // Initialize the SPI Hardware.         (SSIF)
    SPI_init();

    // Initialize the I2C Hardware.         (IPMB/PMB)
    I2C_init();

    // Initialize the Ethernet Hardware.    (LAN)
    ETH_init();
}
Exemplo n.º 11
0
Arquivo: OS.c Projeto: tach4455/EE345M
// ******* OS_Launch *********************
// start the scheduler, enable interrupts
// Inputs: number of 20ns clock cycles for each time slice
//        ( Maximum of 24 bits)
// Outputs: none (does not return)
void OS_Launch(unsigned long theTimeSlice) {

  long curPriority;
  unsigned long curTimeSlice;

  gTimeSlice = theTimeSlice;

  // Get priority of next thread
  curPriority = (*RunPt).priority;

  // Calculate timeslice for priority of next thread
  curTimeSlice = calcTimeSlice(curPriority);
  SysTickPeriodSet(curTimeSlice);

  // Enable sleeping decrementer
  TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
  TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
  TimerEnable(TIMER1_BASE, TIMER_A);
  IntEnable(INT_TIMER1A);

  // Enable and reset Systick
  SysTickEnable();
  SysTickIntEnable();
  NVIC_ST_CURRENT_R = 0;
  IntEnable(FAULT_SYSTICK);

  StartOS(); // Assembly language function that initilizes stack for running

  while(1) {
  }
}
Exemplo n.º 12
0
//*****************************************************************************
//
//! SysTick Initialization 
//!
//! \param None
//!
//! \return None
//!
//*****************************************************************************
tBoolean
SysTickInit(void)
{

    //
    // Query the current system clock rate.
    //
    g_ulClockRate = 80000000;

    //
    // Set up for the system tick calculations. We keep copies of the number
    // of milliseconds per cycle and the rounding error to prevent the need
    // to perform these calculations on every interrupt (the macros are not
    // merely static values).
    //
    g_ulSysTickCount = 0;
    g_ulSysTickMs = SYSTICK_RELOAD_MS;
    g_ulSysTickRounding = SYSTICK_CYCLE_ROUNDING;

    //
    // Set up the system tick to run and interrupt when it times out.
    //
    SysTickIntEnable();
    SysTickPeriodSet(SYSTICK_RELOAD_VALUE);
    SysTickEnable();

    return(true);
}
Exemplo n.º 13
0
Arquivo: OS.c Projeto: tach4455/EE345M
// ******** OS_Suspend ************
// suspend execution of currently running thread
// scheduler will choose another thread to execute
// Can be used to implement cooperative multitasking
// Same function as OS_Sleep(0)
// input:  none
// output: none
void OS_Suspend(void) {

  long curPriority;
  unsigned long curTimeSlice;
  volatile int i;

  OS_DisableInterrupts();

  // Determines NextPt
  Scheduler();

  // Get priority of next thread and calculate timeslice
  curPriority = (*NextPt).priority;
  curTimeSlice = calcTimeSlice(curPriority);

  // Sets next systick period, does not rest counting
  SysTickPeriodSet(curTimeSlice);

  // Write to register forces systick to reset counting
  NVIC_ST_CURRENT_R = 0;

  IntPendSet(FAULT_PENDSV);
  OS_EnableInterrupts();

  return;
}
Exemplo n.º 14
0
void SystickInit(uint8_t report)
{
	//启动系统计时器
	//1us一次systick中断
	SysTickPeriodSet(SysCtlClockGet());
	SysTickEnable();
}
Exemplo n.º 15
0
void Timer::init() {

	*(portNVIC_SYSPRI2) |= portNVIC_SYSTICK_PRI;
	SysTickPeriodSet((SysCtlClockGet() * Timer::microsecondsInterval) / 1000000);
	microTimeInterval=Timer::microsecondsInterval;
        SysTickIntEnable();
}
Exemplo n.º 16
0
//*****************************************************************************
//
//! Initializes the user interface.
//!
//! This function initializes the user interface modules (ethernet),
//! preparing them to operate.
//!
//! \return None.
//
//*****************************************************************************
void
UIInit(void)
{
	//
	// Initialize the UART.
	//
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);
	ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	UARTStdioInit(0);
	UARTprintf("\033[2JEK-LM3S9B92 Plane-Power control board\n");
    
    //
    // Initialize the Ethernet user interface. Use DHCP
    //
    UIEthernetInit( true );

    //
    // Configure SysTick to provide a periodic user interface interrupt.
    //
    SysTickPeriodSet( ROM_SysCtlClockGet() / UI_INT_RATE );
    SysTickIntEnable();
    SysTickEnable();
}
Exemplo n.º 17
0
int NetworkConnectTLS(Network *n, char* addr, int port, SlSockSecureFiles_t* certificates, unsigned char sec_method, unsigned int cipher, char server_verify)
{
    SlSockAddrIn_t sAddr;
    int addrSize;
    int retVal;
    unsigned long ipAddress;

    retVal = sl_NetAppDnsGetHostByName(addr, strlen(addr), &ipAddress, AF_INET);
    if (retVal < 0) {
        return -1;
    }

    sAddr.sin_family = AF_INET;
    sAddr.sin_port = sl_Htons((unsigned short)port);
    sAddr.sin_addr.s_addr = sl_Htonl(ipAddress);

    addrSize = sizeof(SlSockAddrIn_t);

    n->my_socket = sl_Socket(SL_AF_INET, SL_SOCK_STREAM, SL_SEC_SOCKET);
    if (n->my_socket < 0) {
        return -1;
    }

    SlSockSecureMethod method;
    method.secureMethod = sec_method;
    retVal = sl_SetSockOpt(n->my_socket, SL_SOL_SOCKET, SL_SO_SECMETHOD, &method, sizeof(method));
    if (retVal < 0) {
        return retVal;
    }

    SlSockSecureMask mask;
    mask.secureMask = cipher;
    retVal = sl_SetSockOpt(n->my_socket, SL_SOL_SOCKET, SL_SO_SECURE_MASK, &mask, sizeof(mask));
    if (retVal < 0) {
        return retVal;
    }

    if (certificates != NULL) {
        retVal = sl_SetSockOpt(n->my_socket, SL_SOL_SOCKET, SL_SO_SECURE_FILES, certificates->secureFiles, sizeof(SlSockSecureFiles_t));
        if (retVal < 0)
        {
            return retVal;
        }
    }

    retVal = sl_Connect(n->my_socket, (SlSockAddr_t *)&sAddr, addrSize);
    if (retVal < 0) {
        if (server_verify || retVal != -453) {
            sl_Close(n->my_socket);
            return retVal;
        }
    }

    SysTickIntRegister(SysTickIntHandler);
    SysTickPeriodSet(80000);
    SysTickEnable();

    return retVal;
}
Exemplo n.º 18
0
void SystickIntInit(){
	//Enables Systick
	SysTickIntEnable();
	//Registers the Systick interrupt handler
	SysTickIntRegister(SystickIntHandler);
	//Set the countdown time to about .1 ms
	SysTickPeriodSet(90000);
}
Exemplo n.º 19
0
/// User code entry point ///
///
int main(void)
{
    char adr, value;
    //int i = 0;

    // Initialize
    //
    ROM_SysCtlClockSet (SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
    // 1ms SysTick
    SysTickPeriodSet(SysCtlClockGet() / 1000);
    SysTickIntEnable();
    SysTickEnable();

    // Serial console
    Launchpad_UART_Init();

    // Booster pack
    BP_RFID_Init();
    IntMasterEnable();

    printf("[START]\n");

    for (;;)
    {
        printf("> ");
        switch(UARTgetc())
        {
        case 'c':
            adr = UARTgetc();
            printf("[direct command 0x%02x]\n", adr);
            BP_RFID_TRF_Write_Command(adr);
            break;

        case 'w':
            adr = UARTgetc();
            value = UARTgetc();
            BP_RFID_TRF_Write_Register(adr, value);
            printf("[write 0x%02x < 0x%02x]\n");
            break;

        case 'r':
            adr = UARTgetc();
            printf("[read 0x%02x > 0x%02x]\n", adr, BP_RFID_TRF_Read_Register(adr));
            break;

        case 'x':
            BP_ISO15693_Init();
            break;

        case '\n':
        case '\r':
            break;

        default:
            printf("[unknown command]\n");
        }
    }
}
Exemplo n.º 20
0
//*****************************************************************************
//
// This is the main loop that runs the application.
//
//*****************************************************************************
int
main(void)
{
    //
    // Set the clocking to run from the PLL at 50MHz.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);
/*
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    GPIOPinConfigure(GPIO_PG4_USB0EPEN);
    GPIOPinTypeUSBDigital(GPIO_PORTG_BASE, GPIO_PIN_4);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
    GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
*/
    //
    //
    // Set the system tick to fire 100 times per second.
    //
    SysTickPeriodSet(SysCtlClockGet() / SYSTICKS_PER_SECOND);
    SysTickIntEnable();
    SysTickEnable();

    //
    // Pass the USB library our device information, initialize the USB
    // controller and connect the device to the bus.
    //
    USBDHIDMouseInit(0, (tUSBDHIDMouseDevice *)&g_sMouseDevice);
    USBDHIDMouseRemoteWakeupRequest((void *)&g_sMouseDevice);
    //
    // Drop into the main loop.
    //
    while(1)
    {
        //
        // Wait for USB configuration to complete.
        //
        while(!g_bConnected)
        {
        }
        //
        // Now keep processing the mouse as long as the host is connected.
        //
        while(g_bConnected)
        {
            //
            // If it is time to move the mouse then do so.
            //
            if(HWREGBITW(&g_ulCommands, TICK_EVENT) == 1)
            {
                HWREGBITW(&g_ulCommands, TICK_EVENT) = 0;
                MoveHandler();
            }
        }
    }
}
Exemplo n.º 21
0
Arquivo: time.c Projeto: x893/OpenBLT
/************************************************************************************//**
** \brief     Initializes the timer.
** \return    none.
**
****************************************************************************************/
void TimeInit(void)
{
  /* configure the SysTick timer for 1 ms period */
  SysTickPeriodSet((unsigned long)SysCtlClockGet() / 1000);
  SysTickEnable();
  SysTickIntEnable();
  /* reset the millisecond counter */
  TimeSet(0);
} /*** end of TimeInit ***/
Exemplo n.º 22
0
/*************************************************************************************************
 *	Initializes the system clock to run from the crystal
 *		and enables the board's systick functionality.
 ************************************************************************************************/
void systemInit() {
    // Set the clocking to run directly from the crystal.
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

    // Configure and Enable SysTick mechanism
    SysTickPeriodSet(SysCtlClockGet() / SYSTICK_FREQUENCY);
    SysTickIntRegister(sysTickISR);
    SysTickIntEnable();
    SysTickEnable();
}
Exemplo n.º 23
0
void TimerInit(void)
{
	//
	// Set up and enable the SysTick timer.  It will be used as a reference
	// for the delay loop.  
	//
	SysTickPeriodSet(SysCtlClockGet()/TIMER_FREQ);
	SysTickEnable();
	SysTickIntEnable();
}
Exemplo n.º 24
0
/*
*********************************************************************************************************
*                                     void SysTickInit(void)
* Description:  This function is to init the systick.
*
* Argument(s) : none
* Return(s)   : none
*
* Note(s)     : none.
*********************************************************************************************************
*/
_BSP_EVK_V10_BSP_INIT_
void SysTickInit(void)
{
    SysTickDisable();

    SysTickClkSourceSet(NVIC_SYSTICKCTRL_CLKIN);
    SysTickPeriodSet(10);

    SysTickEnable();
}
Exemplo n.º 25
0
int
main(void)
{

	
		
	//set clock	
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);


   
        

     //PB1
     SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
     GPIOPadConfigSet(GPIO_PORTB_BASE,GPIO_PIN_1,GPIO_STRENGTH_4MA,GPIO_PIN_TYPE_STD);
     GPIODirModeSet(GPIO_PORTB_BASE,GPIO_PIN_1,GPIO_DIR_MODE_IN);
     GPIOPortIntRegister(GPIO_PORTB_BASE, PortBIntHandler);
     GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_1, GPIO_BOTH_EDGES);
     GPIOPinIntEnable(GPIO_PORTB_BASE, GPIO_PIN_1);

        
    // Status
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_2,GPIO_STRENGTH_4MA,GPIO_PIN_TYPE_STD);
        GPIODirModeSet(GPIO_PORTF_BASE,GPIO_PIN_2,GPIO_DIR_MODE_OUT);  

    //UART
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600,
    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                   UART_CONFIG_PAR_NONE));
    IntEnable(INT_UART0);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
   
    IntPrioritySet(INT_UART0, 0x7F);
                
    IntPrioritySet(INT_GPIOB,0x80);
    IntMasterEnable();
    SysTickIntRegister(SysTickHandler);                  
    SysTickPeriodSet(SysCtlClockGet()/10000);   // 0.1ms
    SysTickIntEnable();
    waitTime = 0;                   // initialize
    waitTime2 = 0;
    SysTickEnable();
    while(1)
    {
 

    }
    
}
Exemplo n.º 26
0
//*****************************************************************************
//
// Init SysTick timer.  
// 
//
//*****************************************************************************
void
InitSysTick(void)
{
  // Configure SysTick to occur X times per second, to use as a time
    // reference.  Enable SysTick to generate interrupts.
    //
    unsigned long debug = SysCtlClockGet();
    SysTickPeriodSet(SysCtlClockGet()/SYSTICK_PER_MS);
    SysTickIntEnable();
    SysTickEnable();
}
Exemplo n.º 27
0
//****************************************************************************
//
//! Initializes the task scheduler.
//!
//! \param ulTicksPerSecond sets the basic frequency of the SysTick interrupt
//!   used by the scheduler to determine when to run the various task functions.
//!
//! This function must be called during application startup to configure the
//! SysTick timer.  This is used by the scheduler module to determine when each
//! of the functions provided in the g_psSchedulerTable array is called.
//!
//! The caller is responsible for ensuring that SchedulerSysTickIntHandler()
//! has previously been installed in the SYSTICK vector in the vector table
//! and must also ensure that interrupts are enabled at the CPU level.
//!
//! Note that this call does not start the scheduler calling the configured
//! functions.  All function calls are made in the context of later calls to
//! SchedulerRun().  This call merely configures the SysTick interrupt that is
//! used by the scheduler to determine what the current system time is.
//!
//! \return None.
//
//****************************************************************************
void
SchedulerInit(unsigned long ulTicksPerSecond)
{
    ASSERT(ulTicksPerSecond);

    //
    // Configure SysTick for a periodic interrupt.
    //
    SysTickPeriodSet(SysCtlClockGet() / ulTicksPerSecond);
    SysTickEnable();
    SysTickIntEnable();
}
Exemplo n.º 28
0
void cc32xx_init_timer(void)
{
    static int init = 0;

    if (!init) {
        SysTickEnable();
        SysTickIntEnable();
        SysTickIntRegister(sysTickIntHandler);
        SysTickPeriodSet(MPU_FREQUENCY / 1000);/* 1 ms */
        init = 1;
    }
}
Exemplo n.º 29
0
/*
 * Setup the systick timer to generate the tick interrupts at the required
 * frequency.
 */
void prvSetupTimerInterrupt( void )
{
	/* Configure SysTick to interrupt at the requested rate. */
    //
    // Configure SysTick for a 100Hz interrupt.  
    // wants a 10 ms tick.
    //
	SysTickPeriodSet(SysCtlClockGet() / 100);
	SysTickIntEnable();
	SysTickEnable();
	
}
Exemplo n.º 30
0
//*****************************************************************************
// Initilizes hardware
//*****************************************************************************
void InitCortexHardware(void) {
	//
	// Enable FPU
	//
	FPUEnable();
	FPULazyStackingEnable();

	// Set clocking to 50 MHz, due to REV_A1 being a total ass.
	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

	//
	// Configure UART0 for 115200-8n1
	// 
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
  	UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
  	UARTStdioConfig(0, 115200, 16000000);
	UARTFIFODisable(UART0_BASE);
	UARTIntEnable(UART0_BASE, UART_INT_RX);
	UARTprintf("\n\nSystem initializing.\n");

	//
	// Enable SysTick for periodic Interrupts
	// systick is used by command line process
	//
	SysTickEnable();
	SysTickPeriodSet(SysCtlClockGet()/(SYSTICK_TIME/10));
	SysTickIntEnable();
	UARTprintf("- Systick timer enabled.\n");

	//
	// Configure Heartbeat led
	//
	SysCtlPeripheralEnable(HEARTBEAT_CTRL_PORT);
	GPIOPinTypeGPIOOutput(HEARTBEAT_BASE_PORT, HEARTBEAT_PIN);
	GPIOPinWrite(HEARTBEAT_BASE_PORT, HEARTBEAT_PIN, 0xFF);
	UARTprintf("- GPIO enabled. \n");


    //
    // Enable UART interrupts
    //
    IntMasterEnable();
    IntEnable(INT_UART0);
    UARTprintf("- Interrupts enabled.\n");
}