void Board_GPIOs_configure(int32_t gpioNumber,int32_t mode, int32_t pullup) { int32_t pullUpMode=SCU_MODE_INACT; switch(pullup) { case BOARD_GPIO_NOPULL: pullUpMode=SCU_MODE_INACT; break; case BOARD_GPIO_PULLUP: pullUpMode=SCU_MODE_PULLUP; break; case BOARD_GPIO_PULLDOWN: pullUpMode=SCU_MODE_PULLDOWN; break; } Chip_SCU_PinMuxSet(gpiosInfo[gpioNumber].port, gpiosInfo[gpioNumber].portBit, (pullUpMode | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | gpiosInfo[gpioNumber].func)); switch(mode) { case BOARD_GPIO_MODE_INPUT: Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, gpiosInfo[gpioNumber].gpio, gpiosInfo[gpioNumber].gpioBit); // Input break; case BOARD_GPIO_MODE_OUTPUT_PP: Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, gpiosInfo[gpioNumber].gpio, gpiosInfo[gpioNumber].gpioBit); // Output break; case BOARD_GPIO_MODE_OUTPUT_OD: Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, gpiosInfo[gpioNumber].gpio, gpiosInfo[gpioNumber].gpioBit); // Output break; } }
uint32_t PWMSetWidth(uint8_t channel, uint8_t output, uint32_t width) { if (output >= MAX_OUTPUTS || channel > CHANNEL_C_TIMER_INDEX) { return 1; } if (eDVSMode != EDVS_MODE_INTERNAL && channel == 0) { return 1; // channel 0 taken for master/slave mode } LPC_TIMER_T * timer = halTimers[channel].timer; halTimers[channel].witdh[output] = width; halTimers[channel].enabled[output] = ENABLE; /** * Since we have to use the Core M0 to overcome hardware limitations * when the width is 0 or bigger than the period of the wave, * the output is set as GPIO and driven accordingly. */ if (width == 0) { //Set GPIO Low Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, halTimers[channel].portGpio[output], halTimers[channel].pinGpio[output]); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, halTimers[channel].portGpio[output], halTimers[channel].pinGpio[output]); Chip_SCU_PinMuxSet(halTimers[channel].port[output], halTimers[channel].pin[output], halTimers[channel].gpioMode[output]); } else if (width >= timer->MR[2]) { //Set GPIO High Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, halTimers[channel].portGpio[output], halTimers[channel].pinGpio[output]); Chip_GPIO_SetPinOutHigh(LPC_GPIO_PORT, halTimers[channel].portGpio[output], halTimers[channel].pinGpio[output]); Chip_SCU_PinMuxSet(halTimers[channel].port[output], halTimers[channel].pin[output], halTimers[channel].gpioMode[output]); } else { Chip_TIMER_SetMatch(timer, halTimers[channel].timerChannel[output], width); Chip_SCU_PinMuxSet(halTimers[channel].port[output], halTimers[channel].pin[output], halTimers[channel].timerMode[output]); } return 0; }
static rt_err_t rt_led_init(rt_device_t dev) { /*led2 Blue:P0.31 ,led1 Green:P0.30 ,led0 Red:P0_29 P38,P32*/ Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 29, (IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_DIGITAL_EN)); Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 10, (IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_DIGITAL_EN)); Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 9, (IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_DIGITAL_EN)); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 29); Chip_GPIO_SetPinState(LPC_GPIO, 0, 29, false); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 1, 10); Chip_GPIO_SetPinState(LPC_GPIO, 1, 10, true); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 1, 9); Chip_GPIO_SetPinState(LPC_GPIO, 1, 9, true); led.ctrl[0].num = 29; led.ctrl[0].port = 0; led.ctrl[1].num = 10; led.ctrl[1].port = 1; led.ctrl[2].num = 9; led.ctrl[2].port = 1; return RT_EOK; }
void AVALON_LED_Init(void) { /* Set LED's GPIO High */ Chip_GPIO_SetPinState(LPC_GPIO, 0, 8, true); Chip_GPIO_SetPinState(LPC_GPIO, 0, 9, true); Chip_GPIO_SetPinState(LPC_GPIO, 0, 11, true); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 8); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 9); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 11); }
static void Board_LED_Init() { /* Set LEDs as output */ Chip_SCU_PinMuxSet(LED1_PIN_PORT_NUM, LED1_PIN_BIT_NUM, (SCU_PINIO_FAST | LED1_MODE_FUNC)); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, LED1_GPIO_PORT_NUM, LED1_GPIO_BIT_NUM); Chip_SCU_PinMuxSet(LED2_PIN_PORT_NUM, LED2_PIN_BIT_NUM, (SCU_PINIO_FAST | LED2_MODE_FUNC)); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, LED2_GPIO_PORT_NUM, LED2_GPIO_BIT_NUM); /* Set initial states to off (true to disable) */ Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED1_GPIO_PORT_NUM, LED1_GPIO_BIT_NUM, (bool) true); Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED2_GPIO_PORT_NUM, LED2_GPIO_BIT_NUM, (bool) true); }
/* Set pin mux for SSP operation */ static void Init_SSP_PinMux(void) { Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 6, (IOCON_FUNC2 | IOCON_MODE_INACT | IOCON_DIGMODE_EN)); // SCK Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 8, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGMODE_EN)); // MISO Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 9, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGMODE_EN)); // MOSI Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 2, (IOCON_FUNC0 | IOCON_MODE_PULLUP)); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 2); // SSEL(CS) as GPIO output //Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 22, (IOCON_FUNC0 | IOCON_MODE_PULLUP)); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 22); // N_RESET as GPIO output }
int main(void) { uint32_t prompt = 0, rdCnt = 0; volatile bool start_trigger = false; #if defined (M0_SLAVE_PAUSE_AT_MAIN) // Pause execution until debugger attaches and modifies variable while (pause_at_main == 0) { } #endif init_g_vInitHardware(); // usb_g_vInit(); // init the interface SGPIO_spiInit(); // ipc_g_vInit(); // set direction of u4 Chip_SCU_PinMux(2, 10, SCU_MODE_PULLUP, SCU_MODE_FUNC0); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 14); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 0, 14); //SysTick_Config(120000000/1000); // CS_Pin Chip_SCU_PinMux(0, 1, SCU_MODE_PULLUP, SCU_MODE_FUNC0); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 1); Chip_GPIO_SetPinOutHigh(LPC_GPIO_PORT, 0, 1); // radar_g_vDefaultInit(); while (1) { // if (start_trigger) { // radar_mg_vPLLRampUp(); // radar_mg_vPLLActivateModulation(); // for (uint32_t i = 0; i < 40000000; i++) // ; // radar_mg_vPLLDeactivateModulation(); // radar_mg_vPLLRampDown(); // radar_mg_vPLLActivateModulation(); // for (uint32_t i = 0; i < 40000000; i++) // ; // radar_mg_vPLLDeactivateModulation(); // // } } while(1); }
/** * Methods */ void nRF24L01PInit(unsigned char transmitMode) { Chip_GPIO_SetPinOutHigh(LPC_GPIO, CSN_PORT, CSN_PIN); Chip_GPIO_SetPinDIROutput(LPC_GPIO, CSN_PORT, CSN_PIN); Chip_GPIO_SetPinOutLow(LPC_GPIO, NORDIC_CE_PORT, NORDIC_CE_PIN); Chip_GPIO_SetPinDIROutput(LPC_GPIO, NORDIC_CE_PORT, NORDIC_CE_PIN); Chip_GPIO_SetPinDIRInput(LPC_GPIO, NORDIC_IRQ_PORT, NORDIC_IRQ_PIN); nRF24L01P.mode = NRF24L01P_MODE_UNKNOWN; nRF24L01P.transmissionTimeout = -1; nRF24L01P.payloadsinTXFIFO = 0; RFdisable(); Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SSP1); Chip_SSP_Set_Mode(LPC_SSP1, SSP_MODE_MASTER); Chip_SSP_SetFormat(LPC_SSP1, SSP_BITS_8, SSP_FRAMEFORMAT_SPI, SSP_CLOCK_CPHA0_CPOL0); // 8-bit, ClockPhase = 0, ClockPolarity = 0 Chip_SSP_SetBitRate(LPC_SSP1, NRF24L01P_SPI_MAX_DATA_RATE / 2); // 2Mbit, 1/5th the maximum transfer rate for the SPI bus Chip_SSP_Enable(LPC_SSP1); RingBuffer_Init(&nordicTxBuffer, nordictxBufferArray, 1, TX_BUFFER_SIZE); memset(&spi, 0, sizeof(spi)); spi.tx_data = spiBufferTx; spi.rx_data = spiBufferRx; timerDelayUs(NRF24L01P_TIMING_Tundef2pd_us); // Wait for Power-on reset RFsetRegister(NRF24L01P_REG_CONFIG, 0); // Power Down RFsetRegister(NRF24L01P_REG_STATUS, NRF24L01P_STATUS_MAX_RT | NRF24L01P_STATUS_TX_DS | NRF24L01P_STATUS_RX_DR); // Clear any pending interrupts RFsetRegister(NRF24L01P_REG_FEATURE, NRF24L01P_EN_DYN_ACK | NRF24L01P_EN_ACK_PAY | NRF24L01P_EN_DPL); //Enabled no ack packages RFsetRegister(NRF24L01P_REG_DYNPD, NRF24L01P_DPL_P0); RFsetRegister(NRF24L01P_REG_RF_SETUP, 0); // Clear this register // // Setup default configuration // RFdisableAllRxPipes(); RFsetFrequency(DEFAULTNRF24L01P_RF_FREQUENCY); RFsetAirDataRate(DEFAULTNRF24L01P_DATARATE); RFsetRfOutputPower(DEFAULTNRF24L01P_TX_PWR); RFsetCrcWidth(DEFAULTNRF24L01P_CRC); RFsetTxAddress(DEFAULTNRF24L01P_ADDRESS, DEFAULTNRF24L01P_ADDRESS_WIDTH); RFsetRxAddress(DEFAULTNRF24L01P_ADDRESS, DEFAULTNRF24L01P_ADDRESS_WIDTH, NRF24L01P_PIPE_P0); RFenableAutoRetransmit(250, 3); RFdisableAutoAcknowledge(); RFenableAutoAcknowledge(NRF24L01P_PIPE_P0); RFsetTransferSize(DEFAULTNRF24L01P_TRANSFER_SIZE, NRF24L01P_PIPE_P0); nRF24L01P.mode = NRF24L01P_MODE_POWER_DOWN; if (transmitMode) { RFsetTransmitMode(); } else { RFsetReceiveMode(); } RFenable(); }
/** * @brief GPIO initialization. */ void gpioInit(void) { //Chip_GPIO_Init(LPC_GPIO_PORT); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, LCD_BACKLIGHT); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, LCD_BACKLIGHT, 1); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, RANGE_POWER_PIN); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, RANGE_POWER_PIN, 0); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, MoonLander_LED); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, MoonLander_LED, 0); Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, 0, SW_LEFT); Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, 0, SW_RIGHT); }
/* Set up and initialize all required blocks and functions related to the board hardware */ void Board_Init(void) { /* Sets up DEBUG UART */ DEBUGINIT(); /* Updates SystemCoreClock global var with current clock speed */ SystemCoreClockUpdate(); /* Initializes GPIO */ Chip_GPIO_Init(LPC_GPIO_PORT); /* Setup GPIOs for USB demos */ Chip_SCU_PinMuxSet(0x2, 6, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC4)); /* P2_6 USB1_PWR_EN, USB1 VBus function */ Chip_SCU_PinMuxSet(0x2, 5, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)); /* P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION */ Chip_SCU_PinMuxSet(0x1, 7, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC4)); /* P1_7 USB0_PWR_EN, USB0 VBus function Xplorer */ Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 5, 6); /* GPIO5[6] = USB1_PWR_EN */ Chip_GPIO_SetPinState(LPC_GPIO_PORT, 5, 6, true); /* GPIO5[6] output high */ /* Initialize LEDs */ Board_LED_Init(); #if defined(USE_RMII) Chip_ENET_RMIIEnable(LPC_ETHERNET); #else Chip_ENET_MIIEnable(LPC_ETHERNET); #endif }
static void pinConfig(void) { // PE.15 FUNC4 => GPIO7[15] output for CS Chip_SCU_PinMuxSet(0xE, 15, SCU_MODE_PULLDOWN | FUNC4); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 7, 15); // P8.1 FUNC0 => GPIO4[1] input for TP_IRQ Chip_SCU_PinMuxSet(0x8, 1, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | FUNC0); Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, 4, 1); // CS is controlled via PE.15 (GPIO7[16]) and not SSP0_SSEL. // Pin PF.1 should be configured as GPIO and set high. Chip_SCU_PinMuxSet(0xf, 1, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | FUNC4); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 7, 16); Chip_GPIO_SetPinOutHigh(LPC_GPIO_PORT, 7, 16); }
void main (void) { volatile int i; SystemInit (); debug_init (); #ifdef DEBUG_LEVEL debug_set_level (DEBUG_LEVEL); #endif /* configure LED output */ Chip_IOCON_PinMuxSet (LPC_IOCON, LED_STATUS_PIO, IOCON_MODE_INACT | IOCON_FUNC0); Chip_GPIO_SetPinDIROutput (LPC_GPIO, LED_STATUS_PORT, LED_STATUS_PIN); Chip_GPIO_SetPinState (LPC_GPIO, LED_STATUS_PORT, LED_STATUS_PIN, false); DBG_NEWLINE (DBG_LEVEL_INFO); DBG (DBG_LEVEL_INFO, "Debug test firmware (" __GIT_SHA1__ ")"); DBG (DBG_LEVEL_INFO, "Compiled " __DATE__ " at " __TIME__ " on " __BUILD_HOSTNAME__ " using GCC " __VERSION__ " (%d.%d-%d)", __CS_SOURCERYGXX_MAJ__, __CS_SOURCERYGXX_MIN__, __CS_SOURCERYGXX_REV__); DBG (DBG_LEVEL_INFO, "MCU running at %d MHz", SystemCoreClock / 1000000); for (i = 0; i < 0x800000; i++); while (1) { /* toggle LED */ Chip_GPIO_SetPinToggle (LPC_GPIO, LED_STATUS_PORT, LED_STATUS_PIN); DBG (DBG_LEVEL_INFO, "Hello world !!!"); for (i = 0; i < 0x400000; i++); } }
/* NXP_Quick_Jack io initilize detect the mic&gnd */ void QUICKJACK_IO_Init(void) { uint32_t MgAcmpOutVal; uint32_t i = 0; Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, MnGSWENAPINNUM); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, MnGSWENAPINNUM, 1); Chip_IOCON_PinSetMode(LPC_IOCON, IOCON_PIO14, PIN_MODE_INACTIVE); Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, 0, 14); Chip_IOCON_PinSetMode(LPC_IOCON, MnGACMPOUTPIN, PIN_MODE_INACTIVE); Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, 0, MnGACMPOUTPINNUM); MgAcmpOutVal = Chip_GPIO_ReadPortBit(LPC_GPIO_PORT, 0, 6); for(i=0; i<5; i++) { /* waiting a while */ __NOP(); } while(MgAcmpOutVal!= Chip_GPIO_ReadPortBit(LPC_GPIO_PORT, 0, 6)) { for(i=0; i<5; i++) { /* waiting a while */ __NOP(); } MgAcmpOutVal = Chip_GPIO_ReadPortBit(LPC_GPIO_PORT, 0, 6); for(i=0; i<5; i++) { /* waiting a while */ __NOP(); } } /* configured analog switch selectable pin */ Chip_IOCON_PinSetMode(LPC_IOCON, MnGSWSELPIN, PIN_MODE_INACTIVE); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, MnGSWSELPINNUM); if(MgAcmpOutVal==0) { Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, MnGSWSELPINNUM, 1); } else { Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, MnGSWSELPINNUM, 0); } /* enabled analog switch enabled pin */ Chip_IOCON_PinSetMode(LPC_IOCON, MnGSWENAPIN, PIN_MODE_INACTIVE); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, MnGSWENAPINNUM); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, MnGSWENAPINNUM, 0); }
/* Initialize the LEDs on the NXP LPC824 LPCXpresso Board */ static void Board_LED_Init(void) { int i; for (i = 0; i < LEDSAVAIL; i++) { Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, ledBits[i]); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, ledBits[i], true); } }
/* Set GPIO direction for a single GPIO pin */ void Chip_GPIO_SetPinDIR(LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin, bool output) { if (output) { Chip_GPIO_SetPinDIROutput(pGPIO, port, pin); } else { Chip_GPIO_SetPinDIRInput(pGPIO, port, pin); } }
/* Initializes board LED(s) */ static void Board_LED_Init(void) { pinmux_t leds[] = { ONBOARD_LEDS }; Chip_GPIO_Init(LPC_GPIO_PORT); for (int i = 0; i < (sizeof(leds)/sizeof(leds[0])); i++) { Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, TO_PORT(leds[i]), TO_PIN(leds[i])); } }
void tx_init (void) { tx_usage = 0; Chip_IOCON_PinMuxSet (LPC_IOCON, TXE_PIO, TXE_CONFIG); Chip_GPIO_SetPinDIROutput (LPC_GPIO, TXE_PORT, TXE_PIN); Chip_GPIO_SetPinState (LPC_GPIO, TXE_PORT, TXE_PIN, false); }
/* Initialize the LEDs on the NXP LPC54000 LPCXpresso Board */ static void Board_LED_Init(void) { int i; /* Pin muxing setup as part of board_sysinit */ for (i = 0; i < sizeof(ledBits); i++) { Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, ledBits[i]); Chip_GPIO_SetPinState(LPC_GPIO, 0, ledBits[i], true); } }
static void setup_pinmux() { // SPI0 SDCard Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 21, (IOCON_FUNC2 | IOCON_MODE_INACT) | IOCON_DIGMODE_EN); // MOSI Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 20, (IOCON_FUNC2 | IOCON_MODE_INACT) | IOCON_DIGMODE_EN); // SCK Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 22, (IOCON_FUNC3 | IOCON_MODE_INACT) | IOCON_DIGMODE_EN); // MISO Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 23, (IOCON_FUNC4 | IOCON_MODE_INACT) | IOCON_DIGMODE_EN); Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 16, (IOCON_FUNC0 | IOCON_MODE_INACT) | IOCON_DIGMODE_EN); // SSEL // I2C on-board Chip_SYSCTL_PeriphReset(RESET_I2C0); Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 4, (IOCON_FUNC1 | IOCON_FASTI2C_EN) | IOCON_DIGMODE_EN); Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 5, (IOCON_FUNC1 | IOCON_FASTI2C_EN) | IOCON_DIGMODE_EN); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 20); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 2); }
/* Initializes board LED(s) */ static void Board_LED_Init(void) { int idx; for (idx = 0; idx < MAXLEDS; idx++) { /* Set the GPIO as output with initial state off (high) */ Chip_GPIO_SetPinDIROutput(LPC_GPIO, ledports[idx], ledpins[idx]); Chip_GPIO_SetPinState(LPC_GPIO, ledports[idx], ledpins[idx], true); } }
ModeSelect::ModeSelect() { mode_new = -1; mode_act = -1; Chip_IOCON_PinMuxSet(LPC_IOCON, ButtonPin.port, ButtonPin.pin, IOCON_FUNC1 | IOCON_MODE_PULLUP); for (int i=0; i<MODENUM; i++) { Chip_GPIO_SetPinDIROutput(LPC_GPIO, LedPins[i].port, LedPins[i].pin); SetSingleLed(i, false); } }
/* Sets up system pin muxing */ STATIC void SystemSetupMuxing(void) { int i; /* Enable IOCON clock */ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON); for (i = 0; i < (sizeof(pinmuxing) / sizeof(PINMUX_GRP_T)); i++) { Chip_IOCON_PinMuxSet(LPC_IOCON, pinmuxing[i].port, pinmuxing[i].pin, pinmuxing[i].modefunc); } // GPIO0 pins 4,5 (which are also the I2C pins) do not not have internal pull // up and have only open drain mode for output. We set then here as outputs // (low by default) to avoid having floating input. // If needed, the app should switch them to I2C mode and use pullup resistors. Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 4); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 5); }
static void Board_LED_Init() { uint32_t idx; for (idx = 0; idx < (sizeof(gpioLEDBits) / sizeof(io_port_t)); ++idx) { /* Set pin direction and init to off */ Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, gpioLEDBits[idx].port, gpioLEDBits[idx].pin); Chip_GPIO_SetPinState(LPC_GPIO_PORT, gpioLEDBits[idx].port, gpioLEDBits[idx].pin, (bool) true); } }
/* Initialize the LEDs on the NXP_Quick_Jack board */ void Board_LED_Init(void) { uint32_t i; Chip_SWM_DisableFixedPin(SWM_FIXED_XTALIN); //pin 8 Chip_SWM_DisableFixedPin(SWM_FIXED_XTALOUT); //pin 9 //heart beat on pin 13 Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, LEDHEARTBEAT); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, LEDHEARTBEAT, true); }
void Earphone_Init(void) { Chip_IOCON_PinSetMode(LPC_IOCON, IOCON_PIO14, PIN_MODE_INACTIVE); Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, 0, 14); Chip_IOCON_PinSetMode(LPC_IOCON, QUICKJACKTXPIN, PIN_MODE_INACTIVE); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, QUICKJACKTXPINNUM); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, QUICKJACKTXPINNUM, 1); Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM); Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_IOCON); }
void manual_test() { updateMotorDutyCycle(0, 1); test_sd_card(); Chip_SCU_PinMuxSet(LED0_PORT, LED0_PIN, MD_PLN_FAST | FUNC0); // set P0.0 as output Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, LED0_PORT_GPIO, LED0_PIN_GPIO); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, LED0_PORT_GPIO, LED0_PIN_GPIO); for (;;) { timerDelayMs(1000); xprintf("Alive\n"); Chip_GPIO_SetPinToggle(LPC_GPIO_PORT, LED0_PORT_GPIO, LED0_PIN_GPIO); } }
static void flash_spi_pinmux_init(void) { /* Connect the SPI1 signals to port pins */ Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 6 , (IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_DIGITAL_EN)); /* SPI1_SCK */ Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 16, (IOCON_FUNC0 | IOCON_MODE_INACT | IOCON_DIGITAL_EN)); /* SPI1_MISO */ Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 7 , (IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_DIGITAL_EN)); /* SPI1_MOSI */ Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 8 , (IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_DIGITAL_EN)); /* SPI1_SSEL0 */ // Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 15, (IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_DIGITAL_EN)); // Chip_GPIO_SetPinDIROutput(LPC_GPIO, 1, 15); // Chip_GPIO_SetPinState(LPC_GPIO, 1, 15, 1); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 6); Chip_GPIO_SetPinState(LPC_GPIO, 0, 6, 0); /* SPI1_SCK */ Chip_GPIO_SetPinDIRInput(LPC_GPIO, 1, 16); /* SPI1_MISO */ Chip_GPIO_SetPinState(LPC_GPIO, 1, 16, 0); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 7); /* SPI1_MOSI */ Chip_GPIO_SetPinState(LPC_GPIO, 0, 7, 1); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 8);/* SPI1_SSEL0 */ Chip_GPIO_SetPinState(LPC_GPIO, 0, 8, 1); }
void setupTimer(void) { Chip_IOCON_PinMux(LPC_IOCON, 1, 28, 2, 3); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 1, 28); Chip_TIMER_Init(LPC_TIMER0); Chip_TIMER_Reset(LPC_TIMER0); Chip_TIMER_PrescaleSet(LPC_TIMER0, 500); Chip_TIMER_SetMatch(LPC_TIMER0, 0, 16000); Chip_TIMER_ResetOnMatchEnable(LPC_TIMER0, 0); // Chip_TIMER_MatchEnableInt(LPC_TIMER0, 0); Chip_TIMER_ExtMatchControlSet(LPC_TIMER0, RESET, TIMER_EXTMATCH_TOGGLE, 0); Chip_TIMER_Enable(LPC_TIMER0); // NVIC_ClearPendingIRQ(TIMER0_IRQn); // NVIC_EnableIRQ(TIMER0_IRQn); }
//=============================[Leds management]=============================================================================== static void Board_LED_Init() { uint32_t idx; for (idx = 0; idx < (sizeof(gpioLEDBits) / sizeof(io_port_t)); ++idx) { /* Set pin direction and init to off */ Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, gpioLEDBits[idx].port, gpioLEDBits[idx].pin); Chip_GPIO_SetPinState(LPC_GPIO_PORT, gpioLEDBits[idx].port, gpioLEDBits[idx].pin, (bool) false); } rgbPwmInfo.redPwmValue=0; rgbPwmInfo.redPwmCounter=0; rgbPwmInfo.greenPwmValue=0; rgbPwmInfo.greenPwmCounter=0; rgbPwmInfo.bluePwmValue=0; rgbPwmInfo.bluePwmCounter=0; }
void InitSPI () { Chip_IOCON_PinMux(LPC_IOCON,TOUCH_E,IOCON_MODE_PULLUP,IOCON_FUNC0); Chip_GPIO_SetPinDIROutput(LPC_GPIO,TOUCH_E); Chip_IOCON_DisableOD(LPC_IOCON,TOUCH_E); Chip_GPIO_SetPinOutHigh(LPC_GPIO,TOUCH_E); Chip_IOCON_PinMux(LPC_IOCON,TOUCH_CLK,IOCON_MODE_INACT,IOCON_FUNC2); Chip_IOCON_PinMux(LPC_IOCON,TOUCH_MOSI,IOCON_MODE_INACT,IOCON_FUNC2); Chip_IOCON_PinMux(LPC_IOCON,TOUCH_MISO,IOCON_MODE_INACT,IOCON_FUNC2); Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SSP0); Chip_SSP_Set_Mode(LPC_SSP0,SSP_MASTER_MODE); Chip_SSP_SetFormat(LPC_SSP0,SSP_BITS_8,SSP_FRAMEFORMAT_SPI,SSP_CLOCK_CPHA0_CPOL0); Chip_SSP_SetBitRate(LPC_SSP0,1000000 ); Chip_SSP_Enable(LPC_SSP0); }