void timInit ( void ) { PIN_Config(); TIM_Config(); DEBUG_PRINT ( "init successfully\n" ); }
// --------------------------------------------------------------------------- void CPU_GPIO_EnableOutputPin(GPIO_PIN Pin, BOOL InitialState) { LPC_GPIO_T *port_reg = (LPC_GPIO_T *) (LPC_GPIO_PORT_BASE); UINT8 port = LPC43XX_GPIO_PORT(Pin), bit = LPC43XX_GPIO_PIN(Pin); int f = 0; // Configure pin properties f = SCU_PINIO_FAST | ((port > 4) ? (4) : (0)); PIN_Config(Pin, f); PIN_Mode(Pin, PullNone); port_reg->DIR[port] |= (1 << bit); // Output CPU_GPIO_SetPinState(Pin, InitialState); }
// --------------------------------------------------------------------------- void CPU_GPIO_DisablePin(GPIO_PIN Pin, GPIO_RESISTOR ResistorState, UINT32 Direction, GPIO_ALT_MODE AltFunction) { GPIO_IRQ_T *obj; PIN_Config(Pin, 0); // Reset to default for (int i = 0; i < TOTAL_GPIO_INT; i++) { *obj = gpio_irq[i]; if (obj->pin == Pin) { CPU_INTC_DeactivateInterrupt(PIN_INT0_IRQn + obj->ch); obj->pin = GPIO_PIN_NONE; obj->isr = NULL; obj->param = NULL; } } }
// --------------------------------------------------------------------------- BOOL CPU_GPIO_EnableInputPin2(GPIO_PIN Pin, BOOL GlitchFilterEnable, GPIO_INTERRUPT_SERVICE_ROUTINE ISR, void* ISR_Param, GPIO_INT_EDGE IntEdge, GPIO_RESISTOR ResistorState) { LPC_GPIO_T *port_reg = (LPC_GPIO_T *) (LPC_GPIO_PORT_BASE); UINT8 port = LPC43XX_GPIO_PORT(Pin), bit = LPC43XX_GPIO_PIN(Pin); int f = 0; UINT8 ch; // Setup interrupt ch = GPIO_InitIRQ(Pin, ISR, ISR_Param); GPIO_SetIRQ(ch, IntEdge, TRUE); // Configure pin properties f = SCU_PINIO_FAST | ((port > 4) ? (4) : (0)); PIN_Config(Pin, f); PIN_Mode(Pin, PullDown); port_reg->DIR[port] &= ~(1 << bit); // Intput return TRUE; }