コード例 #1
0
ファイル: board_ngx4330.c プロジェクト: Blackclaws/tinyusb
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

}
コード例 #2
0
ファイル: gpio.c プロジェクト: Tempfox/CMSIS-DAP
void gpio_init(void) {

    /* Enable clock and init GPIO outputs */
    LPC_CCU1->CLK_M4_GPIO_CFG = CCU_CLK_CFG_AUTO | CCU_CLK_CFG_RUN;
    while (!(LPC_CCU1->CLK_M4_GPIO_STAT & CCU_CLK_STAT_RUN));

    /* Configure I/O pins: function number, input buffer enabled,  */
    /*                     no pull-up/down                         */
    scu_pinmux(1, 1, GPIO_NOPULL, FUNC0);   /* LED:      GPIO0[8]  */
#ifdef BOARD_LPC4337
    scu_pinmux(2, 11, GPIO_NOPULL, FUNC0);  /* ISPCTRL:  GPIO1[11]  */
#else  
    scu_pinmux(2, 3, GPIO_NOPULL, FUNC4);   /* ISPCTRL:  GPIO5[3]  */
#endif
    scu_pinmux(2, 5, GPIO_PUP,    FUNC4);   /* nRESET:    GPIO5[5] */
    scu_pinmux(2, 6, GPIO_NOPULL, FUNC4);   /* nRESET_OE: GPIO5[6] */

    /* Configure: LED as output (turned off) */
    LPC_GPIO_PORT->CLR[LED_CONNECTED_PORT]  =  (1 << LED_CONNECTED_BIT);
    LPC_GPIO_PORT->DIR[LED_CONNECTED_PORT] |=  (1 << LED_CONNECTED_BIT);

    /* Configure: ISPCTRL as output and high */
    LPC_GPIO_PORT->SET[ISPCTRL_PORT]  = (1 << ISPCTRL_BIT);
    LPC_GPIO_PORT->DIR[ISPCTRL_PORT] |= (1 << ISPCTRL_BIT);

    /* configure Reset Button as input, Reset Output Enable as output LOW */
    LPC_GPIO_PORT->DIR[PORT_nRESET]    &= ~(1 << PIN_nRESET_IN_BIT);
    LPC_GPIO_PORT->CLR[PORT_RESET_TXE]  = (1 << PIN_RESET_TXE_IN_BIT);
    LPC_GPIO_PORT->DIR[PORT_RESET_TXE] |= (1 << PIN_RESET_TXE_IN_BIT);

    /* Use Pin Interrupt 0 */
    LPC_SCU->PINTSEL0 &= ~0xff;
    LPC_SCU->PINTSEL0 |= (PORT_nRESET << 5) | (PIN_nRESET_IN_BIT);
}
コード例 #3
0
ファイル: ads7843.c プロジェクト: JingoC/LCD_DISPLAY
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);
}
コード例 #4
0
ファイル: bsp_NGX.c プロジェクト: magoroku15/nxpUSBlib
void Serial_Init(const uint32_t BaudRate, const bool DoubleSpeed)
{
	UART_CFG_Type UARTConfigStruct;

	/*
	 * Initialize UART1 pin connect
	 */
#if (BOARD == BOARD_XPLORER)
	scu_pinmux(0x1 ,13 , MD_PDN, FUNC1); 				// UART1_TXD
	scu_pinmux(0x1 ,14 , MD_PLN|MD_EZI|MD_ZI, FUNC1); 	// UART1_RXD
#else
	scu_pinmux(0x4 ,1 , MD_PDN|MD_EZI, FUNC6); 	// UART3_TXD
	scu_pinmux(0x4 ,2 , MD_PDN|MD_EZI, FUNC6); 	// UART3_RXD
#endif

	/* Initialize UART Configuration parameter structure to default state:
	 * Baudrate = 9600bps
	 * 8 data bit
	 * 1 Stop bit
	 * None parity
	 */
	UART_ConfigStructInit(&UARTConfigStruct);
	UARTConfigStruct.Baud_rate = BaudRate;	// Re-configure baudrate

	// Initialize DEBUG_UART_PORT peripheral with given to corresponding parameter
	UART_Init(DEBUG_UART_PORT, &UARTConfigStruct);

	// Enable UART Transmit
	UART_TxCmd(DEBUG_UART_PORT, ENABLE);
}
コード例 #5
0
ファイル: bsp_MCB1800_4300.c プロジェクト: openxc/nxp-bsp
void Serial_Init(const uint32_t BaudRate, const bool DoubleSpeed)
{
    UART_CFG_Type UARTConfigStruct;

    /*
     * Initialize UART pin connect
     */
//	scu_pinmux(0x2 ,0 , MD_PDN, FUNC1); 				// UART0_TXD
//	scu_pinmux(0x2 ,1 , MD_PLN|MD_EZI|MD_ZI, FUNC1); 	// UART0_RXD
    scu_pinmux(0x2 ,3 , MD_PDN, FUNC2); 				// UART3_TXD
    scu_pinmux(0x2 ,4 , MD_PLN|MD_EZI|MD_ZI, FUNC2);	// UART3_RXD

    /* Initialize UART Configuration parameter structure to default state:
     * Baudrate = 9600bps
     * 8 data bit
     * 1 Stop bit
     * None parity
     */
    UART_ConfigStructInit(&UARTConfigStruct);
    UARTConfigStruct.Baud_rate = BaudRate;	// Re-configure baudrate

    // Initialize uart peripheral with given to corresponding parameter
    UART_Init(DEBUG_UART_PORT, &UARTConfigStruct);

    // Enable UART Transmit
    UART_TxCmd(DEBUG_UART_PORT, ENABLE);
}
コード例 #6
0
ファイル: airspy_core.c プロジェクト: MalcolmRobb/firmware
void pin_setup(void)
{
  int i;
  #ifdef AIRSPY_NOS
  #else /* AIRSPY One/Demo */
  uint8_t serial_clock_rate;
  uint8_t clock_prescale_rate;
  #endif

  /* Configure all GPIO as Input (safe state) */
  GPIO0_DIR = 0;
  GPIO1_DIR = 0;
  GPIO2_DIR = 0;
  GPIO3_DIR = 0;
  GPIO4_DIR = 0;
  GPIO5_DIR = 0;
  GPIO6_DIR = 0;
  GPIO7_DIR = 0;

  /* Pin configuration for all pins */
  for(i = 0; i < GPIO_CONF_NB; i++)
  {
    scu_pinmux(gpio_conf[i].group_pin, gpio_conf[i].scu_conf);
  }

  /* GPIO1[7] on P1_14 as output. */
  GPIO1_DIR |= PIN_EN_R820T;
  disable_r820t_power();

  /* GPIO1[13] on P2_13 as output. */
  GPIO1_DIR |= PIN_EN_BIAST;
  disable_biast_power();

  #ifdef AIRSPY_NOS
    /* GPIO0[12] on P1_17 as output. */
    GPIO0_DIR |= PIN_EN_LED1;
  #else /* AIRSPY One/Demo */
    /* Configure SSP1 Peripheral */
    #define SCU_SSP1_SCK        (P1_19) /* P1_19 */
    scu_pinmux(SCU_SSP1_SCK,  (SCU_SSP_IO | SCU_CONF_FUNCTION1));

    /* Freq About 1.12MHz => Freq = PCLK / (CPSDVSR * [SCR+1]) with PCLK=PLL1=288MHz */
    clock_prescale_rate = 2;
    serial_clock_rate = 128;

    ssp_init(SSP1_NUM,
        SSP_DATA_8BITS,
        SSP_FRAME_SPI,
        SSP_CPOL_0_CPHA_0,
        serial_clock_rate,
        clock_prescale_rate,
        SSP_MODE_NORMAL,
        SSP_MASTER,
        SSP_SLAVE_OUT_ENABLE);
  #endif

  led_off();
}
コード例 #7
0
ファイル: cpld_jtag.c プロジェクト: Aerobota/hackrf
/* set pins as inputs so we don't interfere with an external JTAG device */
void cpld_jtag_release(jtag_t* const jtag) {
	scu_pinmux(SCU_PINMUX_CPLD_TDO, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION4);
	scu_pinmux(SCU_PINMUX_CPLD_TCK, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_PINMUX_CPLD_TMS, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_PINMUX_CPLD_TDI, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	
	gpio_input(jtag->gpio->gpio_tdo);
	gpio_input(jtag->gpio->gpio_tck);
	gpio_input(jtag->gpio->gpio_tms);
	gpio_input(jtag->gpio->gpio_tdi);
}
コード例 #8
0
ファイル: cpld_jtag.c プロジェクト: AmineCherrai/hackrf
/* set pins as inputs so we don't interfere with an external JTAG device */
void cpld_jtag_release(void) {
	scu_pinmux(SCU_PINMUX_CPLD_TDO, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION4);
	scu_pinmux(SCU_PINMUX_CPLD_TCK, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_PINMUX_CPLD_TMS, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_PINMUX_CPLD_TDI, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	
	GPIO_DIR(PORT_CPLD_TDO) &= ~PIN_CPLD_TDO;
	GPIO_DIR(PORT_CPLD_TCK) &= ~PIN_CPLD_TCK;
	GPIO_DIR(PORT_CPLD_TMS) &= ~PIN_CPLD_TMS;
	GPIO_DIR(PORT_CPLD_TDI) &= ~PIN_CPLD_TDI;
}
コード例 #9
0
ファイル: cpld_jtag.c プロジェクト: AmineCherrai/hackrf
void cpld_jtag_setup(void) {
	scu_pinmux(SCU_PINMUX_CPLD_TDO, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION4);
	scu_pinmux(SCU_PINMUX_CPLD_TCK, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_PINMUX_CPLD_TMS, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_PINMUX_CPLD_TDI, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	
	/* TDO is an input */
	GPIO_DIR(PORT_CPLD_TDO) &= ~PIN_CPLD_TDO;

	/* the rest are outputs */
	GPIO_DIR(PORT_CPLD_TCK) |= PIN_CPLD_TCK;
	GPIO_DIR(PORT_CPLD_TMS) |= PIN_CPLD_TMS;
	GPIO_DIR(PORT_CPLD_TDI) |= PIN_CPLD_TDI;
}
コード例 #10
0
ファイル: hackrf_core.c プロジェクト: Ttl/vna
void ssp1_init(void)
{
    gpio_clear(PORT_SOURCE_CE, PIN_SOURCE_CE);
    gpio_set(PORT_SOURCE_LE, PIN_SOURCE_LE);
    gpio_clear(PORT_LO_CE, PIN_LO_LE);
    gpio_set(PORT_LO_LE, PIN_LO_LE);
    gpio_clear(PORT_ATT_LE, PIN_ATT_LE);

	/* Configure SSP1 Peripheral (to be moved later in SSP driver) */
	scu_pinmux(SCU_SSP1_MISO, (SCU_SSP_IO | SCU_CONF_FUNCTION5));
	scu_pinmux(SCU_SSP1_MOSI, (SCU_SSP_IO | SCU_CONF_FUNCTION5));
	scu_pinmux(SCU_SSP1_SCK,  (SCU_SSP_IO | SCU_CONF_FUNCTION1));
    ssp1_set_mode_16bit();
}
コード例 #11
0
static void gpio_setup(void)
{
	/* Configure SCU Pin Mux as GPIO */
	scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_FAST);
	scu_pinmux(SCU_PINMUX_LED2, SCU_GPIO_FAST);
	scu_pinmux(SCU_PINMUX_LED3, SCU_GPIO_FAST);

	scu_pinmux(SCU_PINMUX_EN1V8, SCU_GPIO_FAST);

	scu_pinmux(SCU_PINMUX_BOOT0, SCU_GPIO_FAST);
	scu_pinmux(SCU_PINMUX_BOOT1, SCU_GPIO_FAST);
	scu_pinmux(SCU_PINMUX_BOOT2, SCU_GPIO_FAST);
	scu_pinmux(SCU_PINMUX_BOOT3, SCU_GPIO_FAST);

	/* Configure all GPIO as Input (safe state) */
	GPIO0_DIR = 0;
	GPIO1_DIR = 0;
	GPIO2_DIR = 0;
	GPIO3_DIR = 0;
	GPIO4_DIR = 0;
	GPIO5_DIR = 0;
	GPIO6_DIR = 0;
	GPIO7_DIR = 0;

	/* Configure GPIO as Output */
	GPIO2_DIR |= (PIN_LED1|PIN_LED2|PIN_LED3); /* Configure GPIO2[1/2/8] (P4_1/2 P6_12) as output. */
	GPIO3_DIR |= PIN_EN1V8; /* GPIO3[6] on P6_10  as output. */
}
コード例 #12
0
ファイル: bsp_MCB1800_4300.c プロジェクト: openxc/nxp-bsp
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
}
コード例 #13
0
ファイル: mcp4022.c プロジェクト: Ttl/vna
void mcp_init(void) {
    /* P6_5(GPIO3[4]) = MCP_CS
     * P6_9(GPIO3[5]) = MCP_UD */

    /* Configure the pinmux */
	scu_pinmux(SCU_MCP_CS, SCU_GPIO_NOPULL);
	scu_pinmux(SCU_MCP_UD, SCU_GPIO_NOPULL);

    CS_HIGH();
    UD_HIGH();

    /* Configures the pins as outputs */
	GPIO3_DIR |= (BIT4 | BIT5);

    mcp_val = 32;
}
コード例 #14
0
ファイル: hw_pwm.c プロジェクト: vargin/t1-firmware
int hw_pwm_pin_pulsewidth (int pin, uint32_t pulsewidth)
{
    if (g_APinDescription[pin].alternate != PWM_MODE) {
        return -1; // Not a PWM pin
    }

    // This is the output channel ({8,5,10} on TM-00-04). They're also
    // used as event indicies for convenience,
    int channel = g_APinDescription[pin].pwm_channel;

    // Event N at counter match
    LPC_SCT->EVENT[channel].CTRL = SCT_EVENT_CTRL_MATCH(channel) | SCT_EVENT_CTRL_MATCH_ONLY; // match register 1, match condition only, no state change
    LPC_SCT->EVENT[channel].STATE = (1 << 0); // in state 0
    LPC_SCT->MATCH[channel].U = pulsewidth;
    LPC_SCT->MATCHREL[channel].U = pulsewidth;

    LPC_SCT->OUT[channel].SET = (1 << 0); // Event 0 sets the output
    LPC_SCT->OUT[channel].CLR = (1 << channel); // Event N clears the output

    scu_pinmux(g_APinDescription[pin].port,
               g_APinDescription[pin].pin,
               PUP_DISABLE | PDN_DISABLE,
               g_APinDescription[pin].alternate_func);

    return 0;
}
コード例 #15
0
ファイル: spi.cpp プロジェクト: Svjatogor/PixyFirmware
int Spi::open()
{
	// configure SGPIO bit so we can toggle slave select (SS)
	LPC_SGPIO->OUT_MUX_CFG14 = 4;
	scu_pinmux(0x1, 3, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC5); // SSP1_MISO
	scu_pinmux(0x1, 4, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC5); // SSP1_MOSI 
	scu_pinmux(0x1, 19, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC1); // SSP1_SCK 

	// enable interrupt
	NVIC_EnableIRQ(SSP1_IRQn);

	// sync
	sync();					

	return 0;
}
コード例 #16
0
ファイル: joystick.c プロジェクト: Blackclaws/tinyusb
/******************************************************************************
 *
 * Description:
 *    Initialize the Joystick Driver
 *
 *****************************************************************************/
void joystick_init (void)
{
  /* set to GPIO function for the 5 pins used with the joystick */
  scu_pinmux(	0xa	,	1	,	GPIO_NOPULL	,	FUNC0	);//GPIO4[8]
  scu_pinmux(	0xa	,	2	,	GPIO_NOPULL	,	FUNC0	);//GPIO4[9]
  scu_pinmux(	0xa	,	3	,	GPIO_NOPULL	,	FUNC0	);//GPIO4[10]
  scu_pinmux(	0x9	,	0	,	GPIO_NOPULL	,	FUNC0	);//GPIO4[12]
  scu_pinmux(	0x9	,	1	,	GPIO_NOPULL	,	FUNC0	);//GPIO4[13]

  /* set the pins as inputs */
  GPIO_SetDir(GPIO_PORT, GPIO_PIN_LEFT, 0);
  GPIO_SetDir(GPIO_PORT, GPIO_PIN_RIGHT, 0);
  GPIO_SetDir(GPIO_PORT, GPIO_PIN_UP, 0);
  GPIO_SetDir(GPIO_PORT, GPIO_PIN_DOWN, 0);
  GPIO_SetDir(GPIO_PORT, GPIO_PIN_CENTER, 0);
}
コード例 #17
0
ファイル: feldtest.c プロジェクト: FlorianHeigl/f1rmware
void feldInit(){

scu_pinmux(BY_AMP_PIN,FUNC|BY_AMP_FUNC);
GPIO_DIR(BY_AMP_GPORT) |= BY_AMP_GPIN;

scu_pinmux(BY_AMP_N_PIN,FUNC|BY_AMP_N_FUNC);
GPIO_DIR(BY_AMP_N_GPORT) |= BY_AMP_N_GPIN;

SETUP(TX_AMP);
SETUP(RX_LNA);

scu_pinmux(TX_RX_PIN,FUNC|TX_RX_FUNC);
GPIO_DIR(TX_RX_GPORT) |= TX_RX_GPIN;

scu_pinmux(TX_RX_N_PIN,FUNC|TX_RX_N_FUNC);
GPIO_DIR(TX_RX_N_GPORT) |= TX_RX_N_GPIN;

scu_pinmux(BY_MIX_PIN,FUNC|BY_MIX_FUNC);
GPIO_DIR(BY_MIX_GPORT) |= BY_MIX_GPIN;

SETUP(BY_MIX_N);

scu_pinmux(LOW_HIGH_FILT_PIN,FUNC|LOW_HIGH_FILT_FUNC);
GPIO_DIR(LOW_HIGH_FILT_GPORT) |= LOW_HIGH_FILT_GPIN;

scu_pinmux(LOW_HIGH_FILT_N_PIN,FUNC|LOW_HIGH_FILT_N_FUNC);
GPIO_DIR(LOW_HIGH_FILT_N_GPORT) |= LOW_HIGH_FILT_N_GPIN;

scu_pinmux(CS_VCO_PIN,FUNC|CS_VCO_FUNC);
GPIO_DIR(CS_VCO_GPORT) |= CS_VCO_GPIN;


SETUP(MIXER_EN);
#define OFF(foo) gpio_clear(foo ## _GPORT,foo ## _GPIN);
#define ON(foo) gpio_set(foo ## _GPORT,foo ## _GPIN);

					gpio_clear(BY_MIX_GPORT,BY_MIX_GPIN);
					ON(BY_MIX_N);

					gpio_clear(BY_AMP_GPORT,BY_AMP_GPIN);
					gpio_set(BY_AMP_N_GPORT,BY_AMP_N_GPIN);

					gpio_clear(TX_RX_GPORT,TX_RX_GPIN);
					gpio_set(TX_RX_N_GPORT,TX_RX_N_GPIN);

					gpio_clear(LOW_HIGH_FILT_GPORT,LOW_HIGH_FILT_GPIN);
					gpio_set(LOW_HIGH_FILT_N_GPORT,LOW_HIGH_FILT_N_GPIN);

					gpio_clear(TX_AMP_GPORT,TX_AMP_GPIN);
					gpio_clear(RX_LNA_GPORT,RX_LNA_GPIN);

					gpio_clear(CS_VCO_GPORT,CS_VCO_GPIN);

					OFF(MIXER_EN);

};
コード例 #18
0
ファイル: analogdig.cpp プロジェクト: Svjatogor/PixyFirmware
int AnalogDig::close()
{
	LPC_DAC->CTRL = 0; // disable dac output	
	// set back to MOSI (input)
	scu_pinmux(0x1, 3, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC5); // SSP1_MOSI	 

	return 0;	
}
コード例 #19
0
ファイル: bsp_MCB1800_4300.c プロジェクト: openxc/nxp-bsp
void bsp_init(void)
{
    uint32_t Core_Clock;
    /* Set up core clock */
    CGU_Init();

    /*Init Timer*/
    Core_Clock = CGU_GetPCLKFrequency(CORE_CLOCK_ID);
    SysTick_Config(Core_Clock/100);	/* 10ms Timer */

    /* Initialize the external memory controller */
    vEMC_InitSRDRAM(SDRAM_BASE_ADDR, SDRAM_WIDTH, SDRAM_SIZE_MBITS, SDRAM_DATA_BUS_BITS, SDRAM_COL_ADDR_BITS);

    scu_pinmux(0x9, 5, MD_PUP | MD_EZI, FUNC2);				// P9_5 USB1_PWR_EN, USB1 VBus function
    scu_pinmux(0x2, 5, MD_PLN | MD_EZI | MD_ZI, FUNC2);		// P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION

    scu_pinmux(0x6, 3, MD_PUP | MD_EZI, FUNC1);     		// P6_3 USB0_PWR_EN, USB0 VBus function
}
コード例 #20
0
ファイル: system_LPC43xx.c プロジェクト: Dzenik/FreeRTOS_TEST
/**
 * Disable source clock pheripheral
 *
 * @param  clock source
 * @return none
 *
 * @brief  	Disable clock specific peripherals
 */
void DisableSourceClk(CLKSRC_Type src_clk)
{
	uint32_t i=0;
	const uint32_t PlainEnable = (0x2 << 3);	/* no pull up, no pull down (plain) */

	if(src_clk == SRC_OSC32K)
	{
		LPC_CREG->CREG0 &= ~((1<<1)|(1<<0));	// Disable 32 kHz & 1 kHz on osc32k
		LPC_CREG->CREG0 |= ((1<<3)|(1<<2));		// osc32k in power down and in reset mode
	}
	if(src_clk == SRC_ENET_RX_CLK)scu_pinmux(0xC ,0 , PlainEnable, FUNC0); 	// nc on PC_0 func 0
	if(src_clk == SRC_ENET_TX_CLK)scu_pinmux(0x1 ,19, PlainEnable, FUNC2); 	// nc on P1_19 func 2
	if(src_clk == SRC_XTAL)
	{
		LPC_CGU->XTAL_OSC_CTRL = (1<<0);		// Disable Xo50M
		for(i=0;i<0xFFFF;i++);
	}
}
コード例 #21
0
//====================================================================================
void main()
{
	volatile uint32_t i;
	uint32_t timer_mark;
	//while(1);
	
	SystemInit();
	CGU_Init();

	scu_pinmux(0xE ,7 , MD_PDN, FUNC4); 	// P8.1 : USB0_IND1 LED

	GPIO_SetDir(LED1_PORT,(1<<LED1_BIT), 1);

	GPIO_ClearValue(LED1_PORT,(1<<LED1_BIT));

	// M3Frequency is automatically set when SetClock(BASE_M3_CLK... was called.
	SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)/1000);  				// Generate interrupt @ 1000 Hz
	
	/*for(;;)
	{
		GPIO_ClearValue(LED1_PORT,(1<<LED1_BIT));
		for(i = 0; i < 200000; i++);
		GPIO_SetValue(LED1_PORT,(1<<LED1_BIT));
		for(i = 0; i < 200000; i++);
	}

	while (1)
	{                           					// Loop forever
		timer_mark = msTicks;					// Take timer snapshot 
		while(msTicks < (timer_mark + 100));	// Wait until 100ms has passed
		GPIO_ClearValue(LED1_PORT,(1<<LED1_BIT));				// Turn the LED off
	
		timer_mark = msTicks;					// Take timer snapshot 
		while(msTicks < (timer_mark + 100));	// Wait until 100ms has passed
		GPIO_SetValue(LED1_PORT,(1<<LED1_BIT));				// Turn the LED on
	}*/

	
	
	// Init on-board LED as output
	//GPIO1->FIODIR |= 1 << 18;
	
	// Init SysTick
	//SysTick_Config(SystemFrequency / 1000);		// Generate interrupt every 1 ms
	
	while (1)
	{                           					// Loop forever
		msec = 100;
		while(msec);
		GPIO_ClearValue(LED1_PORT,(1<<LED1_BIT));
		msec = 100;
		while(msec);
		GPIO_SetValue(LED1_PORT,(1<<LED1_BIT));

	}
}
コード例 #22
0
ファイル: i2c.cpp プロジェクト: hateif/pixy
int I2c::open()
{
	// make all pins on the I/O connector high impedance so we can just daisy chain the whole connector together
	scu_pinmux(0x1, 3, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC0); 
	scu_pinmux(0x2, 1, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC4); 	         
	scu_pinmux(0x2, 1, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC4); 	         
	scu_pinmux(0x1, 4, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC0); 	         
	scu_pinmux(0x2, 0, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC4); 	         
	// turn off driver for SS signal so we can wire-or them together
	LPC_SGPIO->GPIO_OENREG = 0;

 	m_pad0 = false;

	NVIC_EnableIRQ(I2C0_IRQn);
	startSlave(); 


	return 0;
}
コード例 #23
0
ファイル: system_LPC43xx.c プロジェクト: Dzenik/FreeRTOS_TEST
/**
 * Enable source clock pheripheral
 *
 * @param  clock source
 * @return none
 *
 * @brief  	Enable clock specific peripherals
 */
void EnableSourceClk(CLKSRC_Type src_clk)
{
	uint32_t i=0;
	const uint32_t PlainEnable = (0x2 << 3);	/* no pull up, no pull down (plain) */


	if(src_clk == SRC_OSC32K)
	{
		LPC_CREG->CREG0 &= ~((1<<3)|(1<<2));		// Active mode of 32 KHz osc and release reset
		LPC_CREG->CREG0 |= (1<<1)|(1<<0);			// Enable 32 kHz & 1 kHz on osc32k
	}
	if(src_clk == SRC_ENET_RX_CLK)scu_pinmux(0xC ,0 , PlainEnable, FUNC3); 	// enet_rx_clk on PC_0 func 3
	if(src_clk == SRC_ENET_TX_CLK)scu_pinmux(0x1 ,19, PlainEnable, FUNC0); 	// enet_tx_clk on P1_19 func 0
	if(src_clk == SRC_XTAL && (LPC_CGU->XTAL_OSC_CTRL&0x1))
	{
		LPC_CGU->XTAL_OSC_CTRL &= ~(1<<0);								// Enable Xo50M
		for(i=0;i<0xFFFF;i++);
	}
}
コード例 #24
0
ファイル: analogdig.cpp プロジェクト: Svjatogor/PixyFirmware
int AnalogDig::open()
{
	// set pin 1 on I/O connector to output	(Use SGPIO because GPIO interferes with pixel sync)
	scu_pinmux(0x1, 3, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC2); //SGPIO10
	LPC_SGPIO->OUT_MUX_CFG10 = 4;
	LPC_SGPIO->GPIO_OENREG = 1<<10;
	LPC_DAC->CTRL =	(1<<3); // enable dac output

	return 0;	
}
コード例 #25
0
void bsp_init(void)
{
	uint32_t Core_Clock;
	/* Set up core clock */
	CGU_Init();

	/* Initialize the external memory controller */
	vEMC_InitSRDRAM(SDRAM_BASE_ADDR, SDRAM_WIDTH, SDRAM_SIZE_MBITS, SDRAM_DATA_BUS_BITS, SDRAM_COL_ADDR_BITS);

	/* Turn on 5V USB VBUS TODO Should be Host-only */
	scu_pinmux(0x9, 5, MD_PUP | MD_EZI, FUNC2);		// P9_5 USB1_VBUS_EN, USB1 VBus function
	scu_pinmux(0x2, 5, MD_PLN | MD_EZI | MD_ZI, FUNC2);		// P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION

#if (BOARD == BOARD_HITEX_A4)
	scu_pinmux(0x6, 3, MD_PUP | MD_EZI, FUNC1);		// P6_3 USB0_PWR_EN, USB0 VBus function
#else
	scu_pinmux(0x2, 3, MD_PUP | MD_EZI, FUNC7);		// USB0 VBus function
#endif
}
コード例 #26
0
ファイル: spectrum.c プロジェクト: neosam/f1rmware
//# MENU spectrum
void spectrum_menu()
{
	lcdClear();
	lcdDisplay();
	getInputWaitRelease();

	// RF initialization from ppack.c:
	dac_init(false);
	cpu_clock_set(204); // WARP SPEED! :-)
	hackrf_clock_init();
	rf_path_pin_setup();
	/* Configure external clock in */
	scu_pinmux(SCU_PINMUX_GP_CLKIN, SCU_CLK_IN | SCU_CONF_FUNCTION1);
	sgpio_configure_pin_functions();
	ON(EN_VDD);
	ON(EN_1V8);
	OFF(MIC_AMP_DIS);
	delayms(500); // doesn't work without
	cpu_clock_set(204); // WARP SPEED! :-)
	si5351_init();
	portapack_init();

	while(1)
	{
		switch(getInput())
		{
			case BTN_UP:
				displayMode=MODE_WATERFALL;
				break;
			case BTN_DOWN:
				displayMode=MODE_SPECTRUM;
				break;
			case BTN_LEFT:
				freq -= 2000000;
				ssp1_set_mode_max2837();
				set_freq(freq);
				break;
			case BTN_RIGHT:
				freq += 2000000;
				ssp1_set_mode_max2837();
				set_freq(freq);
				break;
			case BTN_ENTER:
				//FIXME: unset the callback, reset the clockspeed, tidy up
                nvic_disable_irq(NVIC_DMA_IRQ);
                OFF(EN_VDD);
                OFF(EN_1V8);
                ON(MIC_AMP_DIS);
                systick_set_clocksource(0);
                systick_set_reload(12e6/SYSTICKSPEED/1000);
				return;

		}
	}
}
コード例 #27
0
ファイル: hw_digital.c プロジェクト: hlev/firmware
void hw_digital_startup (uint8_t ulPin) {
    scu_pinmux(g_APinDescription[ulPin].port,
               g_APinDescription[ulPin].pin,
               PUP_ENABLE | PDN_DISABLE | FILTER_ENABLE,
               g_APinDescription[ulPin].func);

    // set the direction
    GPIO_SetDir(g_APinDescription[ulPin].portNum,
                1 << (g_APinDescription[ulPin].bitNum),
                GPIO_INPUT);
}
コード例 #28
0
ファイル: ppack.c プロジェクト: cokesme/f1rmware
//# MENU Apack
void ppack_menu() {
	lcdClear();
	lcdPrintln("PPack port");
	lcdPrintln("");
	lcdPrintln("up=enable");
	lcdDisplay();
	dac_init(false);

	cpu_clock_set(204); // WARP SPEED! :-)
	hackrf_clock_init();
	rf_path_pin_setup();
	/* Configure external clock in */
	scu_pinmux(SCU_PINMUX_GP_CLKIN, SCU_CLK_IN | SCU_CONF_FUNCTION1);

	sgpio_configure_pin_functions();

	ON(EN_VDD);
	ON(EN_1V8);
	OFF(MIC_AMP_DIS);
	complex_s8_t * samples;

	while(1){
		switch(getInputRaw()){
			case BTN_UP:
			    // ON(MIXER_EN); // hackrf does this
			    cpu_clock_set(204); // WARP SPEED! :-)
			    si5351_init();
			    portapack_init();
			    getInputWaitRelease();

			    break;
			case BTN_DOWN:
			    lcdPrintln("file");
			    writeFile("samples.8", (char*)0x20000000,(uintptr_t)s8ram-0x20000000);
			    break;
			case BTN_LEFT:
			    lcdPrintln("reset");
			    s8ram=(complex_s8_t*)0x20000000;
			    break;
			case BTN_RIGHT:
				break;
			case BTN_ENTER:
				return;
		};
		TOGGLE(LED2);
		delayms(40);
		lcdPrint(IntToStr((uintptr_t)s8ram,8,F_HEX));
		lcdPrint(" ");
		lcdPrintln(IntToStr(sctr,7,F_LONG));
		lcdDisplay();
	};
};
コード例 #29
0
ファイル: main.c プロジェクト: Andriiy/Circuit-Boards
int main(void)
{
    SystemInit();
    CGU_Init();


    // Configure GPIO pins connected to LEDs as outputs
    scu_pinmux(D3_SCU_PORT, D3_SCU_PIN, MD_BUK, FUNC4);
    GPIO_SetDir(D3_GPIO_PORT, D3_GPIO_MASK, 1);
    scu_pinmux(D4_SCU_PORT, D4_SCU_PIN, MD_BUK, FUNC4);
    GPIO_SetDir(D4_GPIO_PORT, D4_GPIO_MASK, 1);
    scu_pinmux(D5_SCU_PORT, D5_SCU_PIN, MD_BUK, FUNC4);
    GPIO_SetDir(D5_GPIO_PORT, D5_GPIO_MASK, 1);
    scu_pinmux(D6_SCU_PORT, D6_SCU_PIN, MD_BUK, FUNC4);
    GPIO_SetDir(D6_GPIO_PORT, D6_GPIO_MASK, 1);

    // Configure GPIO pins connected to push buttons as inputs
    scu_pinmux(S1_SCU_PORT, S1_SCU_PIN, MD_BUK | MD_EZI, FUNC4);
    GPIO_SetDir(S1_GPIO_PORT, S1_GPIO_MASK, 0);
    scu_pinmux(S2_SCU_PORT, S2_SCU_PIN, MD_BUK | MD_EZI, FUNC4);
    GPIO_SetDir(S2_GPIO_PORT, S2_GPIO_MASK, 0);
    scu_pinmux(S3_SCU_PORT, S3_SCU_PIN, MD_BUK | MD_EZI, FUNC4);
    GPIO_SetDir(S3_GPIO_PORT, S3_GPIO_MASK, 0);
    scu_pinmux(S4_SCU_PORT, S4_SCU_PIN, MD_BUK | MD_EZI, FUNC4);
    GPIO_SetDir(S4_GPIO_PORT, S4_GPIO_MASK, 0);

    while(1)
    {
        if (GPIO_ReadValue(S1_GPIO_PORT) & S1_GPIO_MASK)
            GPIO_ClearValue(D3_GPIO_PORT, D3_GPIO_MASK);
        else
            GPIO_SetValue(D3_GPIO_PORT, D3_GPIO_MASK);

        if (GPIO_ReadValue(S2_GPIO_PORT) & S2_GPIO_MASK)
            GPIO_ClearValue(D4_GPIO_PORT, D4_GPIO_MASK);
        else
            GPIO_SetValue(D4_GPIO_PORT, D4_GPIO_MASK);

        if (GPIO_ReadValue(S3_GPIO_PORT) & S3_GPIO_MASK)
            GPIO_ClearValue(D5_GPIO_PORT, D5_GPIO_MASK);
        else
            GPIO_SetValue(D5_GPIO_PORT, D5_GPIO_MASK);

        if (GPIO_ReadValue(S4_GPIO_PORT) & S4_GPIO_MASK)
            GPIO_ClearValue(D6_GPIO_PORT, D6_GPIO_MASK);
        else
            GPIO_SetValue(D6_GPIO_PORT, D6_GPIO_MASK);
    }
}
コード例 #30
0
void pin_setup(void) {
	/* Release CPLD JTAG pins */
	scu_pinmux(SCU_PINMUX_TDO, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION4);
	scu_pinmux(SCU_PINMUX_TCK, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_PINMUX_TMS, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_PINMUX_TDI, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
	
	gpio_input(&gpio_tdo);
	gpio_input(&gpio_tck);
	gpio_input(&gpio_tms);
	gpio_input(&gpio_tdi);
	
	/* Configure SCU Pin Mux as GPIO */
	scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_NOPULL);
	scu_pinmux(SCU_PINMUX_LED2, SCU_GPIO_NOPULL);
	scu_pinmux(SCU_PINMUX_LED3, SCU_GPIO_NOPULL);
	scu_pinmux(SCU_PINMUX_LED4, SCU_GPIO_NOPULL);
	
	/* Configure all GPIO as Input (safe state) */
	gpio_init();

	gpio_output(&gpio_led[0]);
	gpio_output(&gpio_led[1]);
	gpio_output(&gpio_led[2]);
	gpio_output(&gpio_led[3]);

	/* enable input on SCL and SDA pins */
	SCU_SFSI2C0 = SCU_I2C0_NOMINAL;

	/* Configure external clock in */
	scu_pinmux(CLK0, SCU_CONF_FUNCTION1 | SCU_CLK_OUT);
	
	/* Enable USB1 controller */
	SCU_SFSUSB = 0x2;
	scu_pinmux(SCU_PINMUX_USB1_EN, SCU_CONF_FUNCTION0);
	gpio_output(&gpio_usb1_en);
	gpio_set(&gpio_usb1_en);
}