/**************************************************************************** Function InitCannonControlService Parameters uint8_t : the priorty of this service Returns bool, false if error in initialization, true otherwise ****************************************************************************/ bool InitCannonControlService ( uint8_t Priority ) { ES_Event ThisEvent; MyPriority = Priority; GPIO_Init(CANNONANGLE_SYSCTL, CANNONANGLE_BASE, CANNON_DIRECTION_PIN, OUTPUT); GPIO_Clear(CANNONANGLE_BASE, CANNON_DIRECTION_PIN); //Initialize Our Input Captures for Encoder InitInputCapture(CANNON_ENCODER_INTERRUPT_PARAMATERS); //Initialize Periodic Interrupt for Control Laws InitPeriodic(CANNON_CONTROL_INTERRUPT_PARAMATERS); //Start the Cannon at Rest setTargetCannonSpeed(0); //Set Hopper to proper position SetPWM_Hopper(HOPPER_DEFAULT_DUTY); // post the initial transition event ThisEvent.EventType = ES_INIT; if (ES_PostToService( MyPriority, ThisEvent) == true) { return true; }else { return false; } }
// *************** Sensor_SPIByte *************** unsigned char Sensor_SPIByte ( PORT_T *port, unsigned char data_write ) { unsigned char data_read; GPIO_Clear ( port->spi_ss_port, port->spi_ss_pin ); data_read = SPI_Send_Read_Byte ( SPI1, data_write ); GPIO_Set ( port->spi_ss_port, port->spi_ss_pin ); return data_read; }
bool LedOff(LedColour colour) { switch (colour) { case ORANGE_LED: GPIO_Clear(PORT_A, ORANGE_LED_PORT_A_11); break; case YELLOW_LED: GPIO_Clear(PORT_A, YELLOW_LED_PORT_A_28); break; case GREEN_LED: GPIO_Clear(PORT_A, GREEN_LED_PORT_A_29); break; case BLUE_LED: GPIO_Clear(PORT_A, BLUE_LED_PORT_A_10); break; default: break; } return (true); }
int main(void) { SIM_COPC = 0x00; //Deshabilito el watchdog CLK_init(); //Activo relojes de PORTA y PORTB, Core Clock = 47.972.352 Hz, Bus Clock = 23.986.176 Hz, desactivo WDOG GPIO_Init(PORT_A, 11, IO_MUX | PULL_UP | PULL_EN); //Selecciono MUX de IO para PTA11 GPIO_Init(PORT_A, 9, IO_MUX | PULL_UP | PULL_EN); //Selecciono MUX de IO para PTA9 GPIO_Init(PORT_A, 10, IO_MUX); //Selecciono MUX de IO para PTA10 GPIO_Init(PORT_A, 8, IO_MUX); //Selecciono MUX de IO para PTA8 GPIO_IO(PORT_A, 11, INPUT); //Configuro PTA11 como entrada GPIO_IO(PORT_A, 9, INPUT); //Configuro PTA9 como entrada GPIO_IO(PORT_A, 10, OUTPUT); //Configuro PTA10 como salida GPIO_IO(PORT_A, 8, OUTPUT); //Configuro PTA8 como salida for (;;) { estado = GPIO_Read(PORT_A, 11); if (!estado) { GPIO_Set(PORT_A, 10); } else if (estado) { GPIO_Clear(PORT_A, 10); } estado1 = GPIO_Read(PORT_A, 9); if (!estado1) { GPIO_Set(PORT_A, 8); } else if (estado1) { GPIO_Clear(PORT_A, 8); } } /* Never leave main */ return 0; }
int main(void) { SIM_COPC = 0x00; //Deshabilito el watchdog CLK_init(); //Activo relojes de PORTA y PORTB, Core Clock = 47.972.352 Hz, Bus Clock = 23.986.176 Hz GPIO_Init(PORT_A, 10, IO_MUX); //Selecciono MUX de IO para PTA10 GPIO_IO(PORT_A, 10, OUTPUT); //Configuro PTA10 como salida for (;;) { GPIO_Set(PORT_A, 10); //PTA10 = 1 time_delay_ms(1000); //Espero 1 segundo GPIO_Clear(PORT_A, 10); //PTA10 = 0 time_delay_ms(1000); //Espero 1 segundo } /* Never leave main */ return 0; }
/* Coloca ativo o chip select do dispositivo slave */ void SPI_BeginTransfer(int csBitId){ //meter csBitId a zero //GPIO_output(0,csBitId); GPIO_Clear(csBitId); }