Пример #1
0
int
main (void)
{
  volatile int i;
  /* Basic chip initialization is taken care of in SystemInit() called
   * from the startup code. SystemInit() and chip settings are defined
   * in the CMSIS system_<part family>.c file.
   */

  /* NVIC is installed inside UARTInit file. */
  UARTInit (115200, 0);

  /* Initialize GPIO (sets up clock) */
  GPIOInit ();

  /* Set LED port pin to output */
  GPIOSetDir (LED_PORT, LED_BIT, 1);

  while (1)
    {				/* Loop forever */
      if (UARTCount != 0)
	{
	  LPC_UART->IER = IER_THRE | IER_RLS;	/* Disable RBR */
	  UARTSend ((uint8_t *) UARTBuffer, UARTCount);
	  UARTCount = 0;
	  LPC_UART->IER = IER_THRE | IER_RLS | IER_RBR;	/* Re-enable RBR */

	  debug_printf ("Hello World!\n");

	  GPIOSetValue (LED_PORT, LED_BIT, LED_ON);
	  for (i = 0; i < 10000; i++);
	  GPIOSetValue (LED_PORT, LED_BIT, LED_OFF);
	}
    }
}
Пример #2
0
/*******************************************************************************
**   Main Function  main()
*******************************************************************************/
int main (void)
{
  uint32_t bitPattern[2];
  uint32_t eventPattern[2];
  SystemCoreClockUpdate();
  GPIOInit();

#if 1
  bitPattern[0] = 0x1<<5;		/* PIO0_5 enabled */
  bitPattern[1] = 0x1<<5;		/* PIO1_5 enabled */
  eventPattern[0] = 0x1<<5;		/* PIO0_5 rising edge */
  eventPattern[1] = 0x0<<5;		/* PIO1_5 falling edge */
  /* GINT0_INT sources OR together */
  GPIOSetGroupedInterrupt( GROUP0, &bitPattern[0], 0, 0, &eventPattern[0] );
#endif

#if 0
  bitPattern[0] = 0x1<<5;		/* PIO0_5 enabled */
  bitPattern[1] = 0x1<<5;		/* PIO1_5 enabled */
  eventPattern[0] = 0x1<<5;		/* PIO0_5 rising edge */
  eventPattern[1] = 0x0<<5;		/* PIO1_5 falling edge */
  /* GINT1_INT sources AND together */
  GPIOSetGroupedInterrupt( GROUP1, &bitPattern[0], 1, 0, &eventPattern[0] );
#endif

  while ( 1 );
}
Пример #3
0
//Function to configure ADC Channels, PWM Channels and GPIO pins for DOF1 Control
void robot_setconfig()
{
	//UART_Init(0,9600);
	ADCInit(ADC_CLK);
	PWMInit();
	GPIOInit();
}
Пример #4
0
void CPUInit(void)
{
	//Initialise GPIO as alternate function: PWM function
	GPIOInit();
	//Setting PWM
	PWMInit();
}
Пример #5
0
int
main (void)
{
	/* Initialize GPIO (sets up clock) */
	GPIOInit ();

	/* Set LED port pin to output */
	GPIOSetDir (LED_PORT, LED_BIT, 1);
	GPIOSetValue (LED_PORT, LED_BIT, LED_OFF);

	/* Init Power Management Routines */
	pmu_init ();

	/* UART setup */
	UARTInit (115200, 0);

	/* CDC USB Initialization */
	init_usbserial ();

	/* Init RFID */
	rfid_init ();

	/* Init emulation triggers */
	trigger_init ();

	/* RUN RFID loop */
	loop_rfid ();

	return 0;
}
Пример #6
0
/*****************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{
  SystemInit();

  GPIOInit();

  /* use port0_1 as input event, interrupt test. */
  GPIOSetDir( PORT0, 1, 0 );
  /* port0_1, single trigger, active high. */
  GPIOSetInterrupt( PORT0, 1, 0, 0, 0 );
  GPIOIntEnable( PORT0, 1 );

  /* use port1_1 as input event, interrupt test. */
  GPIOSetDir( PORT1, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT1, 1, 0, 0, 0 );
  GPIOIntEnable( PORT1, 1 );

  /* use port2_1 as input event, interrupt test. */
  GPIOSetDir( PORT2, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT2, 1, 0, 0, 0 );
  GPIOIntEnable( PORT2, 1 );

  /* use port3_1 as input event, interrupt test. */
  GPIOSetDir( PORT3, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT3, 1, 0, 0, 0 );
  GPIOIntEnable( PORT3, 1 );

  while( 1 );
}
Пример #7
0
static void prvSetupHardware( void )
{
extern unsigned long _vStackTop[], _pvHeapStart[];
unsigned long ulInterruptStackSize;

	/* Initialize GPIO (sets up clock) */
	GPIOInit();
	/* Set LED port pin to output */
	GPIOSetDir(LED_PORT, LED_GREEN_BIT, 1);
	GPIOSetDir(LED_PORT, LED_RED_BIT, 1);
	GPIOSetValue(LED_PORT, LED_GREEN_BIT, 0);
	GPIOSetValue(LED_PORT, LED_RED_BIT, 0);

	PumpsInit();
	FlowrateInit();
	PacketInit(230400);

	/* The size of the stack used by main and interrupts is not defined in
	the linker, but just uses whatever RAM is left.  Calculate the amount of
	RAM available for the main/interrupt/system stack, and check it against
	a reasonable number.  If this assert is hit then it is likely you don't
	have enough stack to start the kernel, or to allow interrupts to nest.
	Note - this is separate to the stacks that are used by tasks.  The stacks
	that are used by tasks are automatically checked if
	configCHECK_FOR_STACK_OVERFLOW is not 0 in FreeRTOSConfig.h - but the stack
	used by interrupts is not.  Reducing the conifgTOTAL_HEAP_SIZE setting will
	increase the stack available to main() and interrupts. */
	ulInterruptStackSize = ( ( unsigned long ) _vStackTop ) - ( ( unsigned long ) _pvHeapStart );
	configASSERT( ulInterruptStackSize > 350UL );

	/* Fill the stack used by main() and interrupts to a known value, so its
	use can be manually checked. */
	memcpy( ( void * ) _pvHeapStart, ucExpectedInterruptStackValues, sizeof( ucExpectedInterruptStackValues ) );
}
Пример #8
0
static void prvSetupHardware( void )
{


	SystemCoreClockUpdate();

    // enable clock to RAM1
	LPC_SYSCON->SYSAHBCLKCTRL |= (1<<26);

	// init GPIO
	GPIOInit();

	// init I2C
	I2CInit(I2CMASTER);

	//init ADC
	ADCInit(ADC_CLK);

	// init SPI ports
	SSP_IOConfig( 0 );
	SSP_Init( 0 );
	SSP_IOConfig( 1 );
	SSP_Init( 1 );

	// init keyboard
	CAP_KEY_Init();

	// init MOSFET pin
	LPC_IOCON->PIO1_25=0x90;
	GPIOSetDir(PIN_MOSFET,1);
}
Пример #9
0
void U_USART1::Init(uint32_t baud) {
	GPIOInit();
	USARTInit(baud);
	NVICInit();

	USART_Cmd(USART1, ENABLE);
}
Пример #10
0
/* ===================================================================*/
void OnChipInit(void)
{
	GPIOInit();
	SPIInit();
	IIC_Init_G();
	IIC_Init_M();
	//SysTick_Init();
}
Пример #11
0
int main(void)
{
	SystemCoreClockUpdate();
	GPIOInit();
	Usart2Init();
	Usart3Init();
	NVIC_EnableIRQ(USART3_IRQn);
	os_sys_init(init);
}
Пример #12
0
int main(void)
{
    GPIOInit();
    ADCInit();
  while(1)
  {
    value = ReadADC1(1) * 0.0822 * 2.54;
  }
}
Пример #13
0
int main(void) {

	SystemCoreClockUpdate();

	GPIOInit();
	GPIOSetDir(PORT_TEST, PIN_TEST, 1); // 1 means output
	GPIOSetBitValue(PORT_TEST, PIN_TEST, 0);

	for(;;);
}
Пример #14
0
void commonInit(void)
{
	platformInit();
	timerInit();
	GPIOInit();
	USB_UserInit();

  	debug_frmwrk_init_clk(CLKFREQ);
	lpc_printf("M4 start\n");
}
Пример #15
0
void Board::init()
{
	initSwitchMatrix();
	initIOCON();
	setupSysClock();
	SystemCoreClockUpdate();
	setupMRT(SystemCoreClock);
	setupSysTick();
	GPIOInit();
}
Пример #16
0
int main(void) {
	/* Basic chip initialization is taken care of in SystemInit() called
	 * from the startup code. SystemInit() and chip settings are defined
	 * in the CMSIS system_<part family>.c file.
	 */

	/* Initialize 32-bit timer 0. TIME_INTERVAL is defined as 10mS */
	/* You may also want to use the Cortex SysTick timer to do this */
	init_timer32(0, TIME_INTERVAL);
	/* Enable timer 0. nOur interrupt handler will begin incrementing
	 * the TimeTick global each time timer 0 matches and resets.
	 */
	enable_timer32(0);

	/* Initialize GPIO (sets up clock) */
	GPIOInit();


	LPC_IOCON->R_PIO0_11 |= 1;

	/* Set LED port pin to output */
	GPIOSetDir(LED_PORT, LED_BIT, 1);




	synth_init();


	int i;
	for (i = 0; i < 6; i++) {
		synth_channels[i].freq = 100 * i;
		synth_channels[i].amp = 1 << (16 - i);
		synth_channels[i].func = SYNTH_SAW;
	}

	while (1) {
		int tmp = 500 * ADCValue[1]/512;
		for (i = 0; i < 6; i++)
			synth_channels[i].freq = tmp*(i+1);

	}
	while (1) /* Loop forever */
	{
		/* Each time we wake up... */
		/* Check TimeTick to see whether to set or clear the LED I/O pin */
		if ((timer32_0_counter % LED_TOGGLE_TICKS) < (LED_TOGGLE_TICKS / 2)) {
			GPIOSetValue(LED_PORT, LED_BIT, LED_OFF);
		} else {
			GPIOSetValue(LED_PORT, LED_BIT, LED_ON);
		}
		/* Go to sleep to save power between timer interrupts */
		__WFI();
	}
}
Пример #17
0
int BuzInit (void)
{
	GPIOInit(BUZZER);

	g_isCicle = 0;
	if (pthread_create(&thrBuz, NULL, buz, NULL) != 0)
	{
		return EXIT_FAILURE;
	}
	return 0;
}
Пример #18
0
/***************************************************************
** 作   者: Songyimiao
** 官    网:http://www.miaowlabs.com
** 淘    宝:http://miaowlabs.taobao.com
** 日   期: 2015年11月29日
** 函数名称: DriversInit
** 功能描述: 底层驱动初始化            
** 输   入:   
** 输   出:   
** 备    注: 
********************喵呜实验室版权所有**************************
***************************************************************/
void DriversInit(void)
{

	GPIOInit();
  	Timer1Init();
	PWMInit();
	Uart1Init();
	Uart2Init();
	Timer3Timer4Init();

}
void boardInit(void)
{
  SystemCoreClockUpdate();
  delayInit();
  GPIOInit();

  #ifdef CFG_PRINTF_UART
    uartInit(CFG_UART_BAUDRATE);
  #endif

  /* Set user LED pin to output and disable it */
  LPC_GPIO->DIR[CFG_LED_PORT] |= (1 << CFG_LED_PIN);
  boardLED(CFG_LED_OFF);

  /* Start Chibi */
  #ifdef CFG_CHIBI
    /* You may need to write a new address to EEPROM if it doesn't exist */
    // uint16_t nodeaddr = 0xCAFE;
    // uint64_t ieeeaddr = 0x123456780000CAFE;
    // writeEEPROM((uint8_t*)CFG_EEPROM_CHIBI_NODEADDR, (uint8_t*)&nodeaddr, sizeof(nodeaddr));
    // writeEEPROM((uint8_t*)CFG_EEPROM_CHIBI_IEEEADDR, (uint8_t*)&ieeeaddr, sizeof(ieeeaddr));
    chb_init();
  #endif

  /* Initialise USB */
  #ifdef CFG_USB
    delay(500);
    usb_init();
  #endif

  /* Initialise the LCD if requested */
  #ifdef CFG_TFTLCD
    lcdInit();
  #endif

  /* Start the command line interface */
  #ifdef CFG_INTERFACE
    cliInit();
  #endif

  /* Initialise the CC3000 WiFi module and connect to an AP */
  #ifdef CFG_CC3000
    /* Setup the CC3000 pins */
    LPC_IOCON ->TRST_PIO0_14  &= ~0x07;
    LPC_IOCON ->TRST_PIO0_14  |= 0x01;
    LPC_IOCON ->PIO0_17       &= ~0x07;
    LPC_IOCON ->PIO0_16       &= ~0x1F;
    LPC_IOCON ->PIO0_16       |= (1<<4);
  #endif

  /* Turn the user LED on after init to indicate that everything is OK */
  boardLED(CFG_LED_ON);
}
Пример #20
0
int main(void)
{
	/* Start led connected to P1.29 and P1.18 */
	LPC_GPIO1->FIODIR |= 0x20040000;
	LPC_GPIO1->FIOSET |= (1 << 29);
	LPC_GPIO1->FIOCLR |= (1 << 18);

	SystemInit(); // lpc1768_startup.c
	SystemCoreClockUpdate();
	GPIOInit();
	TimerInit();
	ValueInit();
	ADCInit();

	comm_init();
//	welcomeMsg();
	set_echo();
	easyWEB_init();
	printchar("at+ndhcp=1\r");
	printchar("at+wa=greenet\r");
	printchar("at+nstcp=20\r");
	printchar("                              \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");

	while(1)
	{
		easyWEB_s_loop();
		//handle_command();	//UART command
		if(UpdateChannel >= 3)
		{
			UpdateChannel = -1;
			ADCRead(0);
			if (mode ==1)  //decide which ADC channel to read when the converter is working in different direction
			{
				Vout = ADCValues(0);
				Vin = ADCValues(1);
			}
			else
			{
				Vout = ADCValues(1);
				Vin = ADCValues(0);
			}
			Iref = ADCValues(2);
			Il = abs (ADCValues(3) - Iref); //get the correct inductor current
			MeanValues();
			BangBang();
			LPC_GPIO1->FIOPIN ^= (1 << 29);
			LPC_GPIO1->FIOPIN ^= (1 << 18);
		}

	}

	return 0;
}
Пример #21
0
//............................................................................
void BSP_init(void) {
    SystemInit();                            // initialize the clocking system

    GPIOInit();                             // initialize GPIO (sets up clock)
    GPIOSetDir(LED_PORT, LED_BIT, 1);            // set port for LED to output

    if (QS_INIT((void *)0) == 0) {       // initialize the QS software tracing
        Q_ERROR();
    }
    QS_OBJ_DICTIONARY(&l_SysTick_Handler);
    QS_OBJ_DICTIONARY(&l_GPIOPortA_IRQHandler);
}
Пример #22
0
int motionInit (void)
{
	g_isCycleLeft = 0;
	g_isCycleRight = 0;
	GPIOInit(WHEEL_RIGHT);
	GPIOInit(WHEEL_RIGHT_REVERSE);
	GPIOInit(WHEEL_LEFT);
	GPIOInit(WHEEL_LEFT_REVERSE);

	if (pthread_create(&thrLeftWheel, NULL, leftPWMTick, NULL) != 0)
	{
		return EXIT_FAILURE;
	}
	
	if (pthread_create(&thrRightWheel, NULL, rightPWMTick, NULL) != 0)
	{
		return EXIT_FAILURE;
	}

	return 0;
}
/*..........................................................................*/
void BSP_init(void) {
    SystemInit();                         /* initialize the clocking system */

    GPIOInit();                          /* initialize GPIO (sets up clock) */
    GPIOSetDir(LED_PORT, LED_BIT, 1);         /* set port for LED to output */

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }

    QS_RESET();
    QS_OBJ_DICTIONARY(&l_SysTick_Handler);
    QS_OBJ_DICTIONARY(&l_PIOINT0_IRQHandler);
}
void boardInit(void)
{
  SystemCoreClockUpdate();
  delayInit();
  GPIOInit();

  #ifdef CFG_PRINTF_UART
    uartInit(CFG_UART_BAUDRATE);
  #endif

  /* Set user LED pin to output and disable it */
  LPC_GPIO->DIR[CFG_LED_PORT] |= (1 << CFG_LED_PIN);
  boardLED(CFG_LED_OFF);

  /* Start Chibi */
  #ifdef CFG_CHIBI
    /* You may need to write a new address to EEPROM if it doesn't exist */
    // uint16_t nodeaddr = 0xCAFE;
    // uint64_t ieeeaddr = 0x123456780000CAFE;
    // writeEEPROM((uint8_t*)CFG_EEPROM_CHIBI_NODEADDR, (uint8_t*)&nodeaddr, sizeof(nodeaddr));
    // writeEEPROM((uint8_t*)CFG_EEPROM_CHIBI_IEEEADDR, (uint8_t*)&ieeeaddr, sizeof(ieeeaddr));
    chb_init();
  #endif

  /* Initialise USB */
  #ifdef CFG_USB
    delay(500);
    usb_init();
  #endif

  /* Initialise the LCD if requested */
  #ifdef CFG_TFTLCD
    lcdInit();
  #endif

  /* Start the command line interface */
  #ifdef CFG_INTERFACE
    cliInit();
  #endif

  /* Start CC3000 WiFi Module */
  #ifdef CFG_CC3000
    // ToDo: Make sure CC3000 pins are multiplexed to the correct function
    //       since the init code only sets gpio dir, etc.
    // ToDo: Init anything else required for the CC3000!
  #endif

  /* Turn the user LED on after init to indicate that everything is OK */
  boardLED(CFG_LED_ON);
}
Пример #25
0
int main (void) 
{ 
  long toggled;
  long swatch, btndur;
  uint8_t btnstate;
  
  SystemInit();
  SystemCoreClockUpdate();  

  start_delay();
  GPIOInit();
  
  pinMode(USERBTN, INPUT);
  pinMode(USERLED, OUTPUT);
  pinMode(LCDBKLT, OUTPUT);
  
  PWM0_tone(PIO1_13, 1320, 100);
	PWM0_tone(PIO1_13, 1540, 100);

  toggled = millis();
  btnstate = HIGH;

  while (1)                                /* Loop forever */
  {
    if ( btnstate == HIGH && digitalRead(PIO0_1) == LOW ) {
      btnstate = LOW;
      swatch = millis();
    } else
    if ( btnstate == LOW && digitalRead(PIO0_1) == HIGH ) {
      btnstate = HIGH;
      if ( millis() >= swatch + 10 ) {
        btndur = millis() - swatch;
      } else {
        btndur = 0;
      }
      if ( btndur > 667 ) {
        digitalToggle(LCDBKLT);
        PWM0_tone(PIO0_8, 1320, 100);
        PWM0_tone(PIO0_8, 1540, 100);
      } else {
        PWM0_tone(PIO0_8, 1100, 100);
        PWM0_tone(PIO0_8, 880, 100);
      }
    }
    if ( millis() >= toggled + 1000 ) {
      digitalToggle(USERLED);
      toggled = millis();
    }
  }
}
Пример #26
0
int main(void)
{
  HAL_Init();

  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);

  Clocks_Config();
    
  GPIOInit();
  SCCB_Init();
  DcmiDma_Init();
  SpiDma_Init();
  
  while(1);
}
Пример #27
0
static void prvSetupHardware( void )
{

	SystemCoreClockUpdate();

    // enable clock to RAM1
	LPC_SYSCON->SYSAHBCLKCTRL |= (1<<26);

	// init GPIO
	GPIOInit();

	// init I2C
	I2CInit(I2CMASTER);

	//init ADC
	ADCInit(ADC_CLK);

	// init SPI ports
	SSP_IOConfig( 0 );
	SSP_Init( 0 );
	SSP_IOConfig( 1 );
	SSP_Init( 1 );

	if (GPIOGetPinValue( PIN_CAL_DET ))
	{
		m_eAppCFGStatus = appANTENNA_CAL;

		// init CLKOUT pin
		LPC_IOCON->PIO0_1=1;        // enable CLKOUT
		LPC_SYSCON->CLKOUTSEL=3;    // select main clock
		LPC_SYSCON->CLKOUTUEN=1;      // update clock source
		LPC_SYSCON->CLKOUTDIV=2;      // divide by 2
	}
	else
	{
		m_eAppCFGStatus = appNFC_KEYB_TEMP_SWITCH;

		// init keyboard
		CAP_KEY_Init();

		// init MOSFET pin
		LPC_IOCON->PIO1_25=0x90;
		GPIOSetDir(PIN_MOSFET,1);
	}

}
Пример #28
0
/***********************************************************************************
 * @prototype       void SystemInit(void)
 * @description     Initializes the device
 * @param           None
 * @return          None
 ***********************************************************************************/
void SystemInit(void)
{
    // Initialize GPIO and peripheral
    GPIOInit();

    // Initialize Timers
    Timer0Init();
	Timer1Init();

    // Initialize UART
    USARTInit(_BAUDRATE);
	
	// Initialize ADC
	ADC_Init();

	// Enable interrupts
    sei();
}
Пример #29
0
int main(void) {
    uint8_t led = 0;

    GPIOInit();

    ADCInit(ADC_CLK);
    init_timer32(0, 10);

    GPIOSetDir(PORT0, 7, 1);

    while (1) {
        uint32_t value = ADCRead(0);
        delay32Ms(0, value);
        GPIOSetValue(PORT0, 7, led);
        led = !led;

    }
    return 0;
}
Пример #30
0
int main (void) {

  GPIOInit();

  // Initialize Timer16_0 to tick at rate of 1/2000th of second.
	// Note that as this is a 16 bit timer, the maximum count we can
	// load into timer is 0xFFFF, or 65535. Default clock speed
	// set up by CMSIS SystemInit function - SystemCoreClock - is
	// 48MHz or 48000000 Hz. Dividing this by 2000 is 24000 which is
	// within appropriate timer16 maximum. This could be extended
	// if timer routine extended to make use of Prescale Counter register
	// Note by default LPC_SYSCON->SYSAHBCLKDIV is 1.
  init_timer16(0, (SystemCoreClock/LPC_SYSCON->SYSAHBCLKDIV)/2000 );

  // Initialize counter that counts Timer16_0 ticks
  timer16_0_counter = 0;

  //Enable Timer16_0
  enable_timer16(0);

  // Set port for LED to output
  GPIOSetDir( LED_PORT, LED_BIT, 1 );

  while (1)                                /* Loop forever */
  {

	// LED is on for 1st half-second
	if ( (timer16_0_counter > 0) && (timer16_0_counter <= 1000) )
	{
	  GPIOSetValue( LED_PORT, LED_BIT, LED_OFF );
	}
	// LED is off for 2nd half-second
	if ( (timer16_0_counter > 1000) && (timer16_0_counter <= 2000) )
	{
		GPIOSetValue( LED_PORT, LED_BIT, LED_ON );
	}
	// Reset counter
	else if ( timer16_0_counter > 2000 )
	{
	  timer16_0_counter = 0;
	}
  }
}