Esempio n. 1
0
/******************************************************************************
 *
 * Description:
 *    Initialize RGB driver
 *
 *****************************************************************************/
void rgb_init (void)
{
    GPIO_SetDir( 2, 0, 1 );
    GPIO_SetDir( 0, (1<<26), 1 );
    GPIO_SetDir( 2, (1<<1), 1 );

}
/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
	PINSEL_CFG_Type PinCfg;

	PinCfg.Funcnum = 0;
	PinCfg.OpenDrain = 0;
	PinCfg.Pinmode = 0;
	PinCfg.Portnum = 2;
	PinCfg.Pinnum = 10;
	PINSEL_ConfigPin(&PinCfg);
	PinCfg.Pinnum = 11;
	PINSEL_ConfigPin(&PinCfg);
	PinCfg.Pinnum = 12;
	PINSEL_ConfigPin(&PinCfg);

    /* is Input */
    GPIO_SetDir(2, (1<<10), 0);
    GPIO_SetDir(2, (1<<11), 0);
    GPIO_SetDir(2, (1<<12), 0);

	/* Enable system update tick timer */
	GPIO_SetDir(LED1_GPIO_PORT_NUM,(1<<LED1_GPIO_BIT_NUM),1); // output
	GPIO_SetDir(LED2_GPIO_PORT_NUM,(1<<LED2_GPIO_BIT_NUM),1); // output

	init_timer( 0, TIMER0_INTERVAL );

	Serial_Init(115200, false);
	LEDs_Init();
	USB_Init();

	/* Create a stdio stream for the serial port for stdin and stdout */
	Serial_CreateStream(NULL);

	//USB_Init();
}
Esempio n. 3
0
void board_init(void)
{
  SystemInit();
  CGU_Init();
	SysTick_Config( CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)/CFG_TICKS_PER_SECOND );	/* 1 ms Timer */

	//------------- USB Bus power HOST ONLY-------------//
	scu_pinmux(0x1, 7, MD_PUP | MD_EZI, FUNC4);	// P1_7 USB0_PWR_EN, USB0 VBus function Xplorer

	scu_pinmux(0x2, 6, MD_PUP | MD_EZI, FUNC4); // P2_6 is configured as GPIO5[6] for USB1_PWR_EN
	GPIO_SetDir   (5, BIT_(6), 1);              // GPIO5[6] is output
	GPIO_SetValue (5, BIT_(6));                 // GPIO5[6] output high

	// Leds Init
	for (uint8_t i=0; i<BOARD_MAX_LEDS; i++)
	{
	  scu_pinmux(leds[i].port, leds[i].pin, MD_PUP|MD_EZI|MD_ZI, FUNC0);
	  GPIO_SetDir(leds[i].port, BIT_(leds[i].pin), 1); // output
	}

#if CFG_UART_ENABLE
	//------------- UART init -------------//
	UART_CFG_Type UARTConfigStruct;

	scu_pinmux(0x6 ,4, MD_PDN|MD_EZI, FUNC2); 	// UART0_TXD
	scu_pinmux(0x6 ,5, MD_PDN|MD_EZI, FUNC2); 	// UART0_RXD

	UART_ConfigStructInit(&UARTConfigStruct);                   // default: baud = 9600, 8 bit data, 1 stop bit, no parity
	UARTConfigStruct.Baud_rate = CFG_UART_BAUDRATE;             // Re-configure baudrate

	UART_Init((LPC_USARTn_Type*) LPC_USART0, &UARTConfigStruct); // Initialize UART port
	UART_TxCmd((LPC_USARTn_Type*) LPC_USART0, ENABLE);           // Enable UART
#endif

}
Esempio n. 4
0
static void allPinsAsOut(void)
{
	GPIO_SetDir(0, 0x0FFFFFFFF, 1);
	GPIO_SetDir(1, 0x0FFFFFFFF, 1);
	GPIO_SetDir(3, 0x0FFFFFFFF, 1);
	GPIO_SetDir(4, 0x0FFFFFFFF, 1);
}
Esempio n. 5
0
/******************************************************************************
 *
 * Description:
 *    Initialize Buttons driver
 *
 *****************************************************************************/
void btn_init (void)
{
    // SW2
    GPIO_SetDir( 2, (1<<11), 0 );
    // SW3
    GPIO_SetDir( 2, (1<<12), 0 );
}
Esempio n. 6
0
void Init_LCD_Pins(void)
{
    // Configure other pins used by the ILI9341 LCD
    // P0.2 = CS, P0.3 = Reset, P0.21 = DC
    PINSEL_CFG_Type LCDPin;
    LCDPin.Portnum = LCD_CS_PORT;
    LCDPin.Pinnum = LCD_CS_PIN;
    LCDPin.Funcnum = PINSEL_FUNC_0; // Use as GPIO
    LCDPin.OpenDrain = PINSEL_PINMODE_NORMAL;
    LCDPin.Pinmode = PINSEL_PINMODE_PULLUP;
    PINSEL_ConfigPin(&LCDPin);
    LCDPin.Portnum = LCD_RESET_PORT;
    LCDPin.Pinnum = LCD_RESET_PIN;
    PINSEL_ConfigPin(&LCDPin);
    LCDPin.Portnum = LCD_DC_PORT;
    LCDPin.Pinnum = LCD_DC_PIN;
    PINSEL_ConfigPin(&LCDPin);

    // Declare LCD pins as output, disable pin masking
    GPIO_SetDir(LCD_CS_PORT, (1 << LCD_CS_PIN), GPIO_DIR_OUTPUT); 	// CS
    GPIO_SetDir(LCD_RESET_PORT, (1 << LCD_RESET_PIN), GPIO_DIR_OUTPUT); 	// Reset
    GPIO_SetDir(LCD_DC_PORT, (1 << LCD_DC_PIN), GPIO_DIR_OUTPUT); 	// DC

    // Initialize CS to 1
	LCD_CS(1);
}
Esempio n. 7
0
void ads7843_init(void)
{
	SSP_CFG_Type SSP_ConfigStruct;
	
  CONFIG_TS_PENIRQ;

	scu_pinmux(0x3,3,MD_PLN_FAST,FUNC2);	// P3.3 connected to SCL/SCLK	func2=SSP0 SCK0
// 	scu_pinmux(0x9,0,MD_PLN_FAST,FUNC7);	// P9.0 connected to nCS		func2=SSP0 SSEL0
 	scu_pinmux(0x9,0,MD_PLN_FAST | MD_EZI,FUNC0);	
	GPIO_SetDir(4,1<<12,1);
	
 	scu_pinmux(0x3,6,MD_PLN_FAST | MD_EZI,FUNC5);	// P3.6 connected to SO			func2=SSP0 MISO0
	GPIO_SetDir(0,1<<6,0);
	
 	scu_pinmux(0x3,7,MD_PLN_FAST ,FUNC5);	// P3.7 connected to nSI		func2=SSP0 MOSI0
// initialize SSP configuration structure to default
	SSP_ConfigStructInit(&SSP_ConfigStruct);
	SSP_ConfigStruct.ClockRate = 100000;
	SSP_ConfigStruct.Databit = SSP_DATABIT_8;
	// Initialize SSP peripheral with parameter given in structure above
	SSP_Init(LPC_SSP0, &SSP_ConfigStruct);

	// Enable SSP peripheral
	SSP_Cmd(LPC_SSP0, ENABLE);
}
Esempio n. 8
0
void LED_Init (void)
{
	PINSEL_CFG_Type PinCfg;

	uint8_t temp;

	PinCfg.Funcnum = 0;
	PinCfg.OpenDrain = 0;
	PinCfg.Pinmode = 0;
	PinCfg.Portnum = 2;
	for (temp = 2; temp <= 6; temp++){
		PinCfg.Pinnum = temp;
		PINSEL_ConfigPin(&PinCfg);
	}

	PinCfg.Funcnum = 0;
	PinCfg.OpenDrain = 0;
	PinCfg.Pinmode = 0;
	PinCfg.Portnum = 1;
	PinCfg.Pinnum = 28;
	PINSEL_ConfigPin(&PinCfg);
	PinCfg.Pinnum = 29;
	PINSEL_ConfigPin(&PinCfg);
	PinCfg.Pinnum = 31;
	PINSEL_ConfigPin(&PinCfg);

	// Set direction to output
	GPIO_SetDir(2, LED2_MASK, 1);
	GPIO_SetDir(1, LED1_MASK, 1);

	/* Turn off all LEDs */
	GPIO_ClearValue(2, LED2_MASK);
	GPIO_ClearValue(1, LED1_MASK);
}
Esempio n. 9
0
/* enable FPGA EN_CORE and EN_IO */
void io_init_fpga_pwrenable(void)
{
    uint32_t i=0;

    PinCfg.Funcnum      = 0;
    PinCfg.OpenDrain    = 0;
    PinCfg.Pinmode      = 0;


    // 1V5 core voltage
    PinCfg.Pinnum       = FPGA_CORE_EN_PIN;
    PinCfg.Portnum      = FPGA_CORE_EN_PORT;
    PINSEL_ConfigPin(&PinCfg);
    GPIO_SetDir(FPGA_CORE_EN_PORT, FPGA_CORE_EN, POUT);
    fpga_pwr_enable_core_low();

    // 3V3 IO voltage
    PinCfg.Pinnum       = FPGA_IO_EN_PIN;
    PinCfg.Portnum      = FPGA_IO_EN_PORT;
    PINSEL_ConfigPin(&PinCfg);
    GPIO_SetDir(FPGA_IO_EN_PORT, FPGA_IO_EN, POUT);
    fpga_pwr_enable_io_low();

    return;
}
Esempio n. 10
0
void setupHardware(void)
{
	// Disable peripherals power.
	SC->PCONP = 0;

	// Enable GPIO power.
	SC->PCONP = PCONP_PCGPIO;

	// Disable TPIU.
	PINCON->PINSEL10 = 0;

	//  Setup the peripheral bus to be the same as the PLL output (64 MHz).
	SC->PCLKSEL0 = 0x05555555;

	// Configure the LEDs.
	vParTestInitialise();

    // Enable push button INT0 pin.
    GPIO_SetDir(PORT_PUSH, PIN_PUSH, 0);

    // Enable joystick pins.
    GPIO_SetDir(PORT_JOY, PIN_JOY_LEFT | PIN_JOY_RIGHT | PIN_JOY_UP | PIN_JOY_DOWN | PIN_JOY_SEL, 0);

	// Enable debug pins.
	GPIO_SetDir(PORT_DEBUG, PIN_DEBUG_0 | PIN_DEBUG_1 | PIN_DEBUG_2 | PIN_DEBUG_3, 1);
}
Esempio n. 11
0
void LEDs_Init(void)
{
    GPIO_SetDir(LED1_GPIO_PORT_NUM,(1<<LED1_GPIO_BIT_NUM),1); // output
    GPIO_SetDir(LED2_GPIO_PORT_NUM,(1<<LED2_GPIO_BIT_NUM),1); // output
    GPIO_SetDir(LED3_GPIO_PORT_NUM,(1<<LED3_GPIO_BIT_NUM),1); // output
    GPIO_SetDir(LED4_GPIO_PORT_NUM,(1<<LED4_GPIO_BIT_NUM),1); // output
}
Esempio n. 12
0
/*******************************************************************************
* Function Name  : TP_Init
* Description    : TSC2046 Initialization
* Input          : None
* Output         : None
* Return         : None
* Attention		 : None
*******************************************************************************/
void TP_Init(void) 
{
    SSP_CFG_Type SSP_ConfigStruct;
	/*
	 * Initialize SPI pin connect
	 * P2.23 - TP_CS - used as GPIO
	 * P2.22 - SCK
	 * P2.26 - MISO
	 * P2.27 - MOSI
	 */

	PINSEL_ConfigPin(2, 23, 0);
	PINSEL_ConfigPin(2, 22, 2);
	PINSEL_ConfigPin(2, 26, 2);
	PINSEL_ConfigPin(2, 27, 2);

    /* P0.16 CS is output */
    GPIO_SetDir(TP_CS_PORT_NUM, (1<<TP_CS_PIN_NUM), 1);
	GPIO_SetValue(TP_CS_PORT_NUM, (1<<TP_CS_PIN_NUM));  

  	PINSEL_ConfigPin(2, 11, 0);	  
	GPIO_SetDir(2, (1<<11), 0);	  /* P2.11 TP_INT is input */

	/* initialize SSP configuration structure to default */
	SSP_ConfigStructInit(&SSP_ConfigStruct);

	SSP_ConfigStruct.ClockRate = 250000;
	SSP_ConfigStruct.CPHA = SSP_CPHA_FIRST;	   //SSP_CPHA_SECOND   SSP_CPHA_FIRST
	SSP_ConfigStruct.CPOL = SSP_CPOL_HI;		  //SSP_CPOL_LO	  SSP_CPOL_HI

	/* Initialize SSP peripheral with parameter given in structure above */
	SSP_Init(LPC_SSP0, &SSP_ConfigStruct);
	/* Enable SSP peripheral */
	SSP_Cmd(LPC_SSP0, ENABLE);
}
Esempio n. 13
0
/** \brief  Set the HITEX1850 module red LED to an on or off state
 *
 *  This function sets the LED to an on or off state for the board.
 *  See CTOUT2.
 *
 *  \param [in]      state  New LED state, 0 = off, !0 = on
 */
void led_set(s32_t state)
{
	/* Only red component is used, set to input to disable, or
	   output drive low to enable */
	if (state)
		GPIO_SetDir(LED_GPIO_PORT_USED, (1 << DEFAULT_COLOR_PIN_BIT), 1);
	else
		GPIO_SetDir(LED_GPIO_PORT_USED, (1 << DEFAULT_COLOR_PIN_BIT), 0);
}
Esempio n. 14
0
void buttonsInit()
{
	GPIO_SetDir(0, 0, GPIO_DIR_INPUT);
	GPIO_SetDir(0, 1, GPIO_DIR_INPUT);
	
	buttonsState.button1pressed = false;
	buttonsState.button2pressed = false;
	
	loadUtcOffsetFromFlash();
}
Esempio n. 15
0
void led_init(void)
{
    // 2.3 
    // 2.4 
    // 0.27 
    // 2.6
    
    GPIO_SetDir(4, (1<<22), 1);
    GPIO_SetDir(4, (1<<23), 1);
    GPIO_SetDir(4, (1<<26), 1);
    GPIO_SetDir(4, (1<<27), 1);
}
void vtInitLED()
{
    /* LEDs on ports 1 and 2 to output (1). */
    // Note that all LED access is through the proper LPC library calls
    GPIO_SetDir(1,partstFIO1_BITS,1);
    GPIO_SetDir(2,partstFIO2_BITS,1);

    /* Start will all LEDs off. */
    GPIO_ClearValue(1,partstFIO1_BITS);
    GPIO_ClearValue(2,partstFIO2_BITS);

}
Esempio n. 17
0
void SetLineInput(void)
{
    uint8_t i;
    for(i = 0 ;i < 8;i++)
    {
        GPIO_SetDir ( KeyBoardConfig[i][0], (1<<KeyBoardConfig[i][1]), GPIO_DIRECTION_INPUT );
    }
    for(i = 0 ;i < 4;i++)
    {
        GPIO_SetDir ( KeyBoardConfig[i][0], (1<<KeyBoardConfig[i][1]), GPIO_DIRECTION_OUTPUT );
        GPIO_OutputValue ( KeyBoardConfig[i][0], (1<<KeyBoardConfig[i][1]), 0 );
    }
}
Esempio n. 18
0
/*********************************************************************//**
 * @brief		Initialize LED
 * @param[in]	None
 * @return 		None
 **********************************************************************/
void LED_Init(void)
{
	//setting two LEDs as output and turn off all
	GPIO_SetDir(PRIVILEGE_LEDPORT,(1<<PRIVILEGE_LED),1);
	GPIO_SetDir(UNPRIVILEGE_LEDPORT,(1<<UNPRIVILEGE_LED),1);
#ifdef MCB_LPC_1768
	GPIO_ClearValue(1,(1<<PRIVILEGE_LED)|(1<<UNPRIVILEGE_LED));
	GPIO_ClearValue(2,(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6));
#elif defined(IAR_LPC_1768)
	GPIO_SetValue(PRIVILEGE_LEDPORT,(1<<PRIVILEGE_LED));
	GPIO_SetValue(UNPRIVILEGE_LEDPORT,(1<<UNPRIVILEGE_LED));
#endif
}
Esempio n. 19
0
/*********************************************************************//**
 * @brief 		Initialize CS pin as GPIO function to drive /CS pin
 * 				due to definition of CS_PORT_NUM and CS_PORT_NUM
 * @param		None
 * @return		None
 ***********************************************************************/
void CS_Init1 (LPC_SSP_TypeDef *SSPx)
{
	if(SSPx == LPC_SSP0)
	{
		GPIO_SetDir(0, _BIT(16), 1);
		GPIO_SetValue(0, _BIT(16));
	}
	else if (SSPx == LPC_SSP1)
	{
		GPIO_SetDir(0, _BIT(6), 1);
		GPIO_SetValue(0, _BIT(6));
	}
}
Esempio n. 20
0
void main(void) {
	uint8_t counter = 0;
	GPIO_SetDir(LED_PORT, LED_PIN, GPIO_Output);
	GPIO_SetDir(KEY_PORT, KEY_PIN, GPIO_Input);
	GPIO_WriteOutput(LED_PORT, LED_PIN, false);
	SYSCON_StartSystick(72*200000); // 0.2s
	blinks = 0;

	while (true) {
		if (!debounced(KEY_PORT, KEY_PIN) && blinks == 0)
			blinks = counter = (counter+1)&7;
	}
}
Esempio n. 21
0
void jtag_init(void)
{
    uint32_t i=0;

    PinCfg.Funcnum      = 0;    // GPIO
    PinCfg.OpenDrain    = 0;
    PinCfg.Pinmode      = 0;

    puts("");
    printf("Init JTAG port pins: TDO, ");

    PinCfg.Portnum      = JTAG_TDOPORT;
    PinCfg.Pinnum       = JTAG_TDOPIN;
    PINSEL_ConfigPin(&PinCfg);

    printf("TDI, ");
    PinCfg.Portnum      = JTAG_TDIPORT;
    PinCfg.Pinnum       = JTAG_TDIPIN;
    PINSEL_ConfigPin(&PinCfg);

    printf("TMS, ");
    PinCfg.Portnum      = JTAG_TMSPORT;
    PinCfg.Pinnum       = JTAG_TMSPIN;
    PINSEL_ConfigPin(&PinCfg);

    printf("TRST, ");
    PinCfg.Portnum      = JTAG_TRSTPORT;
    PinCfg.Pinnum       = JTAG_TRSTPIN;
    PINSEL_ConfigPin(&PinCfg);

    printf("TCK - done\n");
    PinCfg.Portnum      = JTAG_TCKPORT;
    PinCfg.Pinnum       = JTAG_TCKPIN;
    PINSEL_ConfigPin(&PinCfg);

    GPIO_SetDir(JTAG_TDIPORT, JTAG_TDI, 1);
    GPIO_SetDir(JTAG_TDOPORT, JTAG_TDO, 0);
    GPIO_SetDir(JTAG_TMSPORT, JTAG_TMS, 1);
    GPIO_SetDir(JTAG_TCKPORT, JTAG_TCK, 1);
    GPIO_SetDir(JTAG_TRSTPORT, JTAG_TRST, 1);

    GPIO_ClearValue(JTAG_TDIPORT, JTAG_TDI);

    GPIO_ClearValue(JTAG_TMSPORT, JTAG_TMS);
    GPIO_ClearValue(JTAG_TCKPORT, JTAG_TCK);

    GPIO_ClearValue(JTAG_TRSTPORT, JTAG_TRST);
    GPIO_SetValue(  JTAG_TRSTPORT, JTAG_TRST);

    return;
}
Esempio n. 22
0
void LED_init(){
	//TODO lsb first spi mode 0 0?
	
	GPIO_SetDir(LED_OE_PORT, LED_OE_BIT, 1);
	GPIO_SetValue(LED_OE_PORT, LED_OE_BIT);

	GPIO_SetDir(LED_LE_PORT, LED_LE_BIT, 1);
	GPIO_SetValue(LED_LE_PORT, LED_LE_BIT);

	GPIO_SetDir(WF_HIBERNATE_PORT, WF_HIBERNATE_BIT, 0);
	GPIO_SetValu(WF_HIBERNATE_PORT, WF_HIBERNATE_BIT);

	// Initialize SPI pin connect
	PINSEL_CFG_Type PinCfg;
	SSP_CFG_Type SSP_ConfigStruct;
	/* SCK1 */
	PinCfg.Funcnum   = PINSEL_FUNC_2;
	PinCfg.OpenDrain = PINSEL_PINMODE_NORMAL;
	PinCfg.Pinmode   = PINSEL_PINMODE_PULLDOWN;
	PinCfg.Pinnum    = LED_SCK_PIN;
	PinCfg.Portnum   = LED_SCK_PORT;
	PINSEL_ConfigPin(&PinCfg);
	/* MISO1 */
	PinCfg.Pinmode   = PINSEL_PINMODE_PULLUP;
	PinCfg.Pinnum    = LED_MISO_PIN;
	PinCfg.Portnum   = LED_MISO_PORT;
	PINSEL_ConfigPin(&PinCfg);
	/* MOSI1 */
	PinCfg.Pinnum    = LED_MOSI_PIN;
	PinCfg.Portnum   = LED_MOSI_PORT;
	PINSEL_ConfigPin(&PinCfg);

	/* initialize SSP configuration structure */
	SSP_ConfigStruct.CPHA = SSP_CPHA_FIRST;
	SSP_ConfigStruct.CPOL = SSP_CPOL_HI;
	SSP_ConfigStruct.ClockRate = 10000000; /* TLC5927 max freq = 30Mhz */
	SSP_ConfigStruct.Databit = SSP_DATABIT_16;
	SSP_ConfigStruct.Mode = SSP_MASTER_MODE;
	SSP_ConfigStruct.FrameFormat = SSP_FRAME_SPI;
	SSP_Init(LPC_SSP0, &SSP_ConfigStruct);

	RIT_Init(LPC_RIT);
	RIT_TimerConfig(LPC_RIT, TIME_INTERVAL); //TODO: decide on time interval
	NVIC_SetPriority(LPC_RIT, 0); // set according to main.c
	NVIC_EnableIRQ(LPC_RIT);

	/* Enable SSP peripheral */
	SSP_Cmd(LPC_SSP0, ENABLE);

}
Esempio n. 23
0
void LED_Init()
{
   // init direction
   //GPIO_SetDir(LED1.port, LED1.pin, 1);   (USED FOR UART0)
   //GPIO_SetDir(LED2.port, LED2.pin, 1);   (USED FOR UART0)
   GPIO_SetDir(LED3.port, LED3.pin, 1);
   GPIO_SetDir(LED4.port, LED4.pin, 1);
   
   // all power off
   //LED_SetValue(LED1, 0);   (USED FOR UART0)
   //LED_SetValue(LED2, 0);   (USED FOR UART0)
   LED_SetValue(LED3, 0);
   LED_SetValue(LED4, 0);
}
void setup(void) {
#if defined(lpc11c14) || defined(lpc1768)
    
	GPIO_Init();
	GPIO_SetDir(RED_LED_PORT, RED_LED_BIT, 1);
	GPIO_SetDir(YELLOW_LED_PORT, YELLOW_LED_BIT, 1);
    // Register the GPS timer sync
    GPIO_SetFunction(2, 10, GPIO_PIO, GPIO_MODE_NONE);
	GPIO_SetDir(2, 10, 0);
    GPIO_RegisterInterruptHandler(2, 10, 0, 0, 1, &gps_timer_handler);

	InitRTC();
    SetTime("000000"); // FOR DEBUG PURPOSE, REMOVE LATER
	scandal_naive_delay(100000);
	
	// StartOsc();
	   
#else
#ifdef msp43f149
	init_clock();

	P1OUT = 0x00;
	P1SEL = 0x00;
	P1DIR = 0x00;
	P1IES = 0x00;
	P1IE  = 0x00;
	
	P2OUT = 0x00;
	P2SEL = 0x00;
	P2DIR = 0x00;
	P2IES = CAN_INT;
	P2IE  = 0x00;

	P3OUT = 0x00;
	P3SEL = TX | RX;
	P3DIR = TX;

	P4OUT = 0x00;
	P4SEL = 0x00;
	P4DIR = 0x00;

	P5OUT = CAN_CS;
	P5SEL = SIMO1 | SOMI1 | UCLK1;
	P5DIR = CAN_CS | SIMO1 | UCLK1 | YELLOW_LED_BIT | RED_LED_BIT;

	P6SEL = MEAS_12V_PIN;
    
#endif // msp430f149
#endif // lpc1768 || lpc11c14
} // setup
Esempio n. 25
0
/*********************************************************************//**
 * @brief		Initialize LEDs
 * @param[in]	None
 * @return 		None
 **********************************************************************/
void InitLED(void)
{
#ifdef MCB_LPC_1768
/* Use LEDs P1.28 and P1.29*/
	GPIO_SetDir(1, (1<<28)|(1<<29), 1); //set P1.28 and P1.29 is output
	GPIO_ClearValue(1, (1<<28)|(1<<29));//Turn off LEDs
#elif defined (IAR_LPC_1768)
/* Use LED1 (P1.25) and LED2 (P0.4)*/
	GPIO_SetDir(1, (1<<25), 1); //set P1.25 is output
	GPIO_SetDir(0, (1<<4), 1);  //set P0.4 is output
	GPIO_SetValue(1, (1<<25));  //Turn off LED1
	GPIO_SetValue(0, (1<<4));	//Turn off LED2
#endif
}
Esempio n. 26
0
int main() {
	//Initialize system and clocks
	SystemInit();
	SystemCoreClockUpdate();

	//Turn on peripheral clocks for GPIO and I2S
	CLKPWR_ConfigPPWR(CLKPWR_PCONP_PCGPIO, ENABLE);
	CLKPWR_ConfigPPWR(CLKPWR_PCONP_PCI2S, ENABLE);

	//Set direction for LED pin
	GPIO_SetDir(0, (1 << 22), 1);
	//Set direction for ADC control pins
	GPIO_SetDir(1, (1 << 18) | (1 << 21), 1);

	//Initialize buffer pointers to default value
	processActive = buffer3;
	rxActive = buffer1;
	txActive = buffer2;

	//Init the I2S hardware
	initTX(44100, (uint32_t) txActive, (uint32_t) rxActive);

	//Set and Clear control pins for ADC
	GPIO_SetValue(1, (1 << 18));
	GPIO_ClearValue(1, (1 << 21));

	//infinite loop
	while (1) {
		//If the interrupt has set the flag
		if (needsProcessing) {
			//Turn led on to indicate CPU usage
			GPIO_SetValue(0, (1 << 22));

			//Run filter on current buffers
			firFixed(processActive, TRANSFER_SIZE);

			//Rotate buffers
			uint32_t *tmp = processActive;
			processActive = rxActive;
			rxActive = txActive;
			txActive = tmp;

			//Clear flag
			needsProcessing = 0;

			//Turn led off, if the processing takes longer the LED becomes brighter
			GPIO_ClearValue(0, (1 << 22));
		}
	}
}
Esempio n. 27
0
void Joystick_Init(void)
{
    scu_pinmux(0xC ,9 , MD_PUP|MD_EZI|MD_ZI, FUNC4);		// PC_9  as GPIO6[8]
    scu_pinmux(0xC ,11, MD_PUP|MD_EZI|MD_ZI, FUNC4);		// PC_11 as GPIO6[10]
    scu_pinmux(0xC ,12, MD_PUP|MD_EZI|MD_ZI, FUNC4);		// PC_12 as GPIO6[11]
    scu_pinmux(0xC ,13, MD_PUP|MD_EZI|MD_ZI, FUNC4);		// PC_13 as GPIO6[12]
    scu_pinmux(0xC ,14, MD_PUP|MD_EZI|MD_ZI, FUNC4);		// PC_14 as GPIO6[13]

    GPIO_SetDir(JOYSTICK_UP_GPIO_PORT_NUM,(1<<JOYSTICK_UP_GPIO_BIT_NUM),0); 		// input
    GPIO_SetDir(JOYSTICK_DOWN_GPIO_PORT_NUM,(1<<JOYSTICK_DOWN_GPIO_BIT_NUM),0); 	// input
    GPIO_SetDir(JOYSTICK_LEFT_GPIO_PORT_NUM,(1<<JOYSTICK_LEFT_GPIO_BIT_NUM),0); 	// input
    GPIO_SetDir(JOYSTICK_RIGHT_GPIO_PORT_NUM,(1<<JOYSTICK_RIGHT_GPIO_BIT_NUM),0); 	// input
    GPIO_SetDir(JOYSTICK_PRESS_GPIO_PORT_NUM,(1<<JOYSTICK_PRESS_GPIO_BIT_NUM),0); 	// input
}
Esempio n. 28
0
// The platform I/O functions
pio_type platform_pio_op( unsigned port, pio_type pinmask, int op )
{
  pio_type retval = 1;
  
  switch( op )
  {
    case PLATFORM_IO_PORT_SET_VALUE:   
      GPIO_SetValue(port, pinmask);
      break;
    
    case PLATFORM_IO_PIN_SET:
      GPIO_SetValue(port, pinmask);
      break;
    
    case PLATFORM_IO_PIN_CLEAR:
      GPIO_ClearValue(port, pinmask);
      break;
    
    case PLATFORM_IO_PORT_DIR_OUTPUT:
      GPIO_SetDir(port, 0xFFFFFFFF, 1);
      break;    

    case PLATFORM_IO_PIN_DIR_OUTPUT:
      GPIO_SetDir(port, pinmask, 1);
      break;
    
    case PLATFORM_IO_PORT_DIR_INPUT:
      GPIO_SetDir(port, 0xFFFFFFFF, 0);
      break;

    case PLATFORM_IO_PIN_DIR_INPUT:
      GPIO_SetDir(port, pinmask, 0);
      break;    
          
    case PLATFORM_IO_PORT_GET_VALUE:
      retval = GPIO_ReadValue(port);
      break;
    
    case PLATFORM_IO_PIN_GET:
      retval = ( GPIO_ReadValue(port) & pinmask ) ? 1 : 0;
      break;
    
    default:
      retval = 0;
      break;
  }
  return retval;
}
Esempio n. 29
0
void spi_configure (tPinDef SClk, tPinDef Mosi, tPinDef Miso, tPinDef SSel)
{
  PINSEL_CFG_Type PinCfg;

  /*
   * Initialize SPI pin connect
   */
   
  /* SSEL as GPIO, pull-up mounted */
  PinCfg.Funcnum   = PINSEL_FUNC_0;
  PinCfg.OpenDrain = PINSEL_PINMODE_NORMAL;
  PinCfg.Pinmode   = PINSEL_PINMODE_PULLUP;
  PinCfg.Portnum   = SSel.port;
  PinCfg.Pinnum    = SSel.pin_number;
  GPIO_SetDir(SSel.port, _BV(SSel.pin_number), 1);
  PINSEL_ConfigPin(&PinCfg);

  /* SCK alternate function 0b10 */
  PinCfg.Funcnum   = PINSEL_FUNC_2;
  PinCfg.Pinmode   = PINSEL_PINMODE_PULLDOWN;
  PinCfg.Portnum   = SClk.port;
  PinCfg.Pinnum    = SClk.pin_number;
  PINSEL_ConfigPin(&PinCfg);

  /* MISO */
  PinCfg.Pinmode   = PINSEL_PINMODE_PULLUP;
  PinCfg.Portnum   = Miso.port;
  PinCfg.Pinnum    = Miso.pin_number;
  PINSEL_ConfigPin(&PinCfg);

  /* MOSI */
  PinCfg.Portnum   = Mosi.port;
  PinCfg.Pinnum    = Mosi.pin_number;
  PINSEL_ConfigPin(&PinCfg);
 }
Esempio n. 30
0
/*
 *  メインタスク
 */
void main_task(intptr_t exinf)
{

	syslog(LOG_NOTICE, "Sample program starts (exinf = %d).", (int_t) exinf);

		/* GPIO0のLED制御ピンを出力にする */
	GPIO_SetDir(
			0,			// GPIOポート番号
			LEDMASK,	// 操作するビットマスク
			1			// 設定する値
			);

	while(1)
	{
			/* 500m秒待つ */
		SVC_PERROR(tslp_tsk(500));
			/* LED制御ピンをLにする */
		GPIO_ClearValue(
				0,			// GPIOポート番号
				LEDMASK	// 操作するビットマスク
				);
			/* 500m秒待つ */
		SVC_PERROR(tslp_tsk(500));
			/* LED制御ピンをHにする */
		GPIO_SetValue(
				0,			// GPIOポート番号
				LEDMASK	// 操作するビットマスク
				);
	}


	syslog(LOG_NOTICE, "Sample program ends.");
	SVC_PERROR(ext_ker());
	assert(0);
}