コード例 #1
0
ファイル: cpu_usage.c プロジェクト: ninisnanas/Hello-TA
//*****************************************************************************
//
//! Initializes the CPU usage measurement module.
//!
//! \param ui32ClockRate is the rate of the clock supplied to the timer module.
//! \param ui32Rate is the number of times per second that CPUUsageTick() is
//! called.
//! \param ui32Timer is the index of the timer module to use.
//!
//! This function prepares the CPU usage measurement module for measuring the
//! CPU usage of the application.
//!
//! \return None.
//
//*****************************************************************************
void
CPUUsageInit(uint32_t ui32ClockRate, uint32_t ui32Rate, uint32_t ui32Timer)
{
    //
    // Check the arguments.
    //
    ASSERT(ui32ClockRate > ui32Rate);
    ASSERT(ui32Timer < 6);

    //
    // Save the timer index.
    //
    g_ui32CPUUsageTimer = ui32Timer;

    //
    // Determine the number of system clocks per measurement period.
    //
    g_ui32CPUUsageTicks = ui32ClockRate / ui32Rate;

    //
    // Set the previous value of the timer to the initial timer value.
    //
    g_ui32CPUUsagePrevious = 0xffffffff;

    //
    // Enable peripheral clock gating.
    //
    MAP_SysCtlPeripheralClockGating(true);

    //
    // Enable the third timer while the processor is in run mode, but disable
    // it in sleep mode.  It will therefore count system clocks when the
    // processor is running but not when it is sleeping.
    //
    MAP_SysCtlPeripheralEnable(g_pui32CPUUsageTimerPeriph[ui32Timer]);
    MAP_SysCtlPeripheralSleepDisable(g_pui32CPUUsageTimerPeriph[ui32Timer]);

    //
    // Configure the third timer for 32-bit periodic operation.
    //
    MAP_TimerConfigure(g_pui32CPUUsageTimerBase[ui32Timer],
                       TIMER_CFG_PERIODIC);

    //
    // Set the load value for the third timer to the maximum value.
    //
    MAP_TimerLoadSet(g_pui32CPUUsageTimerBase[ui32Timer], TIMER_A, 0xffffffff);

    //
    // Enable the third timer.  It will now count the number of system clocks
    // during which the processor is executing code.
    //
    MAP_TimerEnable(g_pui32CPUUsageTimerBase[ui32Timer], TIMER_A);
}
コード例 #2
0
ファイル: main.c プロジェクト: brians444/tiva-ads1246-lwip
void systick_init()
{
  //
  // Configure SysTick for a periodic interrupt.
  //
  MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / SYSTICKHZ);
  MAP_SysTickEnable();
  MAP_SysTickIntEnable();

  //MAP_IntEnable(INT_GPIOA);
  MAP_IntEnable(INT_GPIOE);
  MAP_IntMasterEnable();

  MAP_SysCtlPeripheralClockGating(false);

  MAP_GPIOIntTypeSet(GPIO_PORTE_BASE, ENC_INT, GPIO_FALLING_EDGE);
  MAP_GPIOPinIntClear(GPIO_PORTE_BASE, ENC_INT);
  MAP_GPIOPinIntEnable(GPIO_PORTE_BASE, ENC_INT);
  UARTprintf("int enabled\n");
}
コード例 #3
0
ファイル: main.c プロジェクト: cubeberg/HomeAutomation
void main(void) {
  static struct uip_eth_addr eth_addr;
  uip_ipaddr_t ipaddr;

  cpu_init();
  uart_init();
  printf("Welcome\n");
  spi_init();
  enc28j60_comm_init();

  printf("Welcome\n");

  enc_init(mac_addr);

  //
  // Configure SysTick for a periodic interrupt.
  //
  MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / SYSTICKHZ);
  MAP_SysTickEnable();
  MAP_SysTickIntEnable();

  //MAP_IntEnable(INT_GPIOA);
  MAP_IntEnable(INT_GPIOE);
  MAP_IntMasterEnable();

  MAP_SysCtlPeripheralClockGating(false);

  printf("int enabled\n");

  MAP_GPIOIntTypeSet(GPIO_PORTE_BASE, ENC_INT, GPIO_FALLING_EDGE);
  MAP_GPIOPinIntClear(GPIO_PORTE_BASE, ENC_INT);
  MAP_GPIOPinIntEnable(GPIO_PORTE_BASE, ENC_INT);

  uip_init();

  eth_addr.addr[0] = mac_addr[0];
  eth_addr.addr[1] = mac_addr[1];
  eth_addr.addr[2] = mac_addr[2];
  eth_addr.addr[3] = mac_addr[3];
  eth_addr.addr[4] = mac_addr[4];
  eth_addr.addr[5] = mac_addr[5];

  uip_setethaddr(eth_addr);

#define DEFAULT_IPADDR0 10
#define DEFAULT_IPADDR1 0
#define DEFAULT_IPADDR2 0
#define DEFAULT_IPADDR3 201

#define DEFAULT_NETMASK0 255
#define DEFAULT_NETMASK1 255
#define DEFAULT_NETMASK2 255
#define DEFAULT_NETMASK3 0

#undef STATIC_IP

#ifdef STATIC_IP
  uip_ipaddr(ipaddr, DEFAULT_IPADDR0, DEFAULT_IPADDR1, DEFAULT_IPADDR2,
	     DEFAULT_IPADDR3);
  uip_sethostaddr(ipaddr);
  printf("IP: %d.%d.%d.%d\n", DEFAULT_IPADDR0, DEFAULT_IPADDR1,
	     DEFAULT_IPADDR2, DEFAULT_IPADDR3);
  uip_ipaddr(ipaddr, DEFAULT_NETMASK0, DEFAULT_NETMASK1, DEFAULT_NETMASK2,
	     DEFAULT_NETMASK3);
  uip_setnetmask(ipaddr);
#else
  uip_ipaddr(ipaddr, 0, 0, 0, 0);
  uip_sethostaddr(ipaddr);
  printf("Waiting for IP address...\n");
  uip_ipaddr(ipaddr, 0, 0, 0, 0);
  uip_setnetmask(ipaddr);
#endif

  httpd_init();

#ifndef STATIC_IP
  dhcpc_init(mac_addr, 6);
  dhcpc_request();
#endif

  long lPeriodicTimer, lARPTimer;
  lPeriodicTimer = lARPTimer = 0;

  int i; // = MAP_GPIOPinRead(GPIO_PORTA_BASE, ENC_INT) & ENC_INT;
  while(true) {
    //MAP_IntDisable(INT_UART0);
    MAP_SysCtlSleep();
    //MAP_IntEnable(INT_UART0);

    //i = MAP_GPIOPinRead(GPIO_PORTA_BASE, ENC_INT) & ENC_INT;
    /*while(i != 0 && g_ulFlags == 0) {
      i = MAP_GPIOPinRead(GPIO_PORTA_BASE, ENC_INT) & ENC_INT;
      }*/

    if( HWREGBITW(&g_ulFlags, FLAG_ENC_INT) == 1 ) {
      HWREGBITW(&g_ulFlags, FLAG_ENC_INT) = 0;
      enc_action();
    }

    if(HWREGBITW(&g_ulFlags, FLAG_SYSTICK) == 1) {
      HWREGBITW(&g_ulFlags, FLAG_SYSTICK) = 0;
      lPeriodicTimer += SYSTICKMS;
      lARPTimer += SYSTICKMS;
      //printf("%d %d\n", lPeriodicTimer, lARPTimer);
    }

    if( lPeriodicTimer > UIP_PERIODIC_TIMER_MS ) {
      lPeriodicTimer = 0;
      int l;
      for(l = 0; l < UIP_CONNS; l++) {
	uip_periodic(l);

	//
	// If the above function invocation resulted in data that
	// should be sent out on the network, the global variable
	// uip_len is set to a value > 0.
	//
	if(uip_len > 0) {
	  uip_arp_out();
	  enc_send_packet(uip_buf, uip_len);
	  uip_len = 0;
	}
      }

      for(l = 0; l < UIP_UDP_CONNS; l++) {
	uip_udp_periodic(l);
	if( uip_len > 0) {
	  uip_arp_out();
	  enc_send_packet(uip_buf, uip_len);
	  uip_len = 0;
	}
      }
    }

    if( lARPTimer > UIP_ARP_TIMER_MS) {
      lARPTimer = 0;
      uip_arp_timer();
    }

  }

}
コード例 #4
0
int main(void)
{
	MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |SYSCTL_XTAL_12MHZ); //50MHZ

	//
	// Enable peripherals to operate when CPU is in sleep.
	//
	MAP_SysCtlPeripheralClockGating(true);

	//
	// Configure SysTick to occur 1000 times per second, to use as a time
	// reference.  Enable SysTick to generate interrupts.
	//
	MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / SYSTICKS_PER_SECOND);
	MAP_SysTickIntEnable();
	MAP_SysTickEnable();

	//
	// Get the current processor clock frequency.
	//
	ulClockMS = MAP_SysCtlClockGet() / (3 * 1000);

	// init Serial Comm
	initSerialComm(230400);

	// init SSI0 in slave mode
	initSPIComm();

#ifdef DEBUG
	UARTprintf("Setting up PID\n");
#endif
	initCarPID();
#ifdef DEBUG
	UARTprintf("done\n");
#endif

#ifdef DEBUG
	UARTprintf("Setting up PWM ... \n");
#endif
	configurePWM();
	configureGPIO();
#ifdef DEBUG
	UARTprintf("done\n");
#endif

#ifdef DEBUG
	UARTprintf("Setting up Servo ... \n");
#endif
	servo_init();
	servo_setPosition(90);
#ifdef DEBUG
	UARTprintf("done\n");
#endif

#ifdef DEBUG
	UARTprintf("Starting QEI...");
#endif
	encoder_init();
#ifdef DEBUG
	UARTprintf("done\n");
#endif

#ifdef USE_I2C
#ifdef DEBUG
	UARTprintf("Setting up I2C\n");
#endif
	//I2C
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	MAP_GPIOPinTypeI2C(GPIO_PORTB_AHB_BASE,GPIO_PIN_2 | GPIO_PIN_3);
	MAP_I2CMasterInitExpClk(I2C0_MASTER_BASE,SysCtlClockGet(),true);  //false = 100khz , true = 400khz
	I2CMasterTimeoutSet(I2C0_MASTER_BASE, 1000);
#ifdef DEBUG
	UARTprintf("done\n");
#endif
#endif

#ifdef USE_I2C
#ifdef USE_INA226
#ifdef DEBUG
	UARTprintf("Setting up INA226\n");
#endif
	initINA226();
#ifdef DEBUG
	UARTprintf("done\n");
#endif
#endif
#endif


	while (1)
	{

	}
}
コード例 #5
0
ファイル: tw_extension.c プロジェクト: IMEMS/gtbelib
/****************************
 * System Control Functions *
 ****************************/
void twe_initSystem80MHz(void) {
	// Set system clock to 80 MHz (400MHz main PLL (divided by 5 - uses DIV400 bit)  [16MHz external xtal drives PLL]
	SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
	MAP_SysCtlPeripheralClockGating(true); // Enable peripherals to operate when CPU is in sleep.
}