//! //! \return none //! //! \brief Initializes Push Button Ports and Pins // //***************************************************************************** void Button_IF_Init(P_INT_HANDLER S2InterruptHdl,P_INT_HANDLER S3InterruptHdl ) { // // Set Interrupt Type for GPIO // MAP_GPIOIntTypeSet(GPIOA1_BASE,GPIO_PIN_5,GPIO_FALLING_EDGE); MAP_GPIOIntTypeSet(GPIOA2_BASE,GPIO_PIN_6,GPIO_FALLING_EDGE); g_S3InterruptHdl = S3InterruptHdl; g_S2InterruptHdl = S2InterruptHdl; // // Register Interrupt handler // osi_InterruptRegister(INT_GPIOA1,(P_OSI_INTR_ENTRY)GPIOs3IntHandler, INT_PRIORITY_LVL_1); osi_InterruptRegister(INT_GPIOA2,(P_OSI_INTR_ENTRY)GPIOs2IntHandler, INT_PRIORITY_LVL_1); // // Enable Interrupt // MAP_GPIOIntClear(GPIOA1_BASE,GPIO_PIN_5); MAP_GPIOIntEnable(GPIOA1_BASE,GPIO_INT_PIN_5); MAP_GPIOIntClear(GPIOA2_BASE,GPIO_PIN_6); MAP_GPIOIntEnable(GPIOA2_BASE,GPIO_INT_PIN_6); }
//**************************************************************************** // //! Main function //! //! \param none //! //! This function //! 1. Configures the GPIOA1 and A2 interrupt. //! //! \return None. // //**************************************************************************** int main() { // // Initialize Board configurations // BoardInit(); // // Power on the corresponding GPIO port B for 9,10,11. // Set up the GPIO lines to mode 0 (GPIO) // PinMuxConfig(); // // Configure the GPIO13 - SW2 interrupt // MAP_GPIOIntRegister(GPIOA1_BASE, GPIOA1IntHandler); MAP_GPIOIntTypeSet(GPIOA1_BASE, GPIO_PIN_5, GPIO_RISING_EDGE); // // Configure the GPIO22 interrupt // MAP_GPIOIntRegister(GPIOA2_BASE, GPIOA2IntHandler); MAP_GPIOIntTypeSet(GPIOA2_BASE, GPIO_PIN_6, GPIO_RISING_EDGE); // // Enable GPIO13 Interrupt // MAP_GPIOIntClear(GPIOA1_BASE, GPIO_PIN_5); MAP_IntPendClear(INT_GPIOA1); MAP_IntEnable(INT_GPIOA1); MAP_GPIOIntEnable(GPIOA1_BASE, GPIO_PIN_5); // // Enable GPIO22 Interrupt // MAP_GPIOIntClear(GPIOA2_BASE, GPIO_PIN_6); MAP_IntPendClear(INT_GPIOA2); MAP_IntEnable(INT_GPIOA2); MAP_GPIOIntEnable(GPIOA2_BASE, GPIO_PIN_6); // // Infinite loop. All processing happens now in the interrupt handler. while (1) { } return 0; }
//**************************************************************************** // //! Configures the GPIO selected as input to generate interrupt on activity //! //! \param uiGPIOPort is the GPIO port address //! \param ucGPIOPin is the GPIO pin of the specified port //! \param uiIntType is the type of the interrupt (refer gpio.h) //! \param pfnIntHandler is the interrupt handler to register //! //! This function //! 1. Sets GPIO interrupt type //! 2. Registers Interrupt handler //! 3. Enables Interrupt //! //! \return None // //**************************************************************************** void GPIO_IF_ConfigureNIntEnable(unsigned int uiGPIOPort, unsigned char ucGPIOPin, unsigned int uiIntType, void (*pfnIntHandler)(void)) { // // Set GPIO interrupt type // MAP_GPIOIntTypeSet(uiGPIOPort,ucGPIOPin,uiIntType); // // Register Interrupt handler // #ifdef USE_TIRTOS osi_InterruptRegister(GetPeripheralIntNum(uiGPIOPort), pfnIntHandler, INT_PRIORITY_LVL_1); #else MAP_GPIOIntRegister(uiGPIOPort,pfnIntHandler); #endif // // Enable Interrupt // MAP_GPIOIntClear(uiGPIOPort,ucGPIOPin); MAP_GPIOIntEnable(uiGPIOPort,ucGPIOPin); }
//**************************************************************************** // //! Configures the GPIO selected as input to generate interrupt on activity //! //! \param uiGPIOPort is the GPIO port address //! \param ucGPIOPin is the GPIO pin of the specified port //! \param uiIntType is the type of the interrupt (refer gpio.h) //! \param pfnIntHandler is the interrupt handler to register //! //! This function //! 1. Sets GPIO interrupt type //! 2. Registers Interrupt handler //! 3. Enables Interrupt //! //! \return None // //**************************************************************************** void GPIO_IF_ConfigureNIntEnable(unsigned int uiGPIOPort, unsigned char ucGPIOPin, unsigned int uiIntType, void (*pfnIntHandler)(void)) { // // Set GPIO interrupt type // MAP_GPIOIntTypeSet(uiGPIOPort,ucGPIOPin,uiIntType); // // Register Interrupt handler // #if defined(USE_TIRTOS) || defined(USE_FREERTOS) || defined(SL_PLATFORM_MULTI_THREADED) // USE_TIRTOS: if app uses TI-RTOS (either networking/non-networking) // USE_FREERTOS: if app uses Free-RTOS (either networking/non-networking) // SL_PLATFORM_MULTI_THREADED: if app uses any OS + networking(simplelink) osi_InterruptRegister(GetPeripheralIntNum(uiGPIOPort), pfnIntHandler, INT_PRIORITY_LVL_1); #else MAP_IntPrioritySet(GetPeripheralIntNum(uiGPIOPort), INT_PRIORITY_LVL_1); MAP_GPIOIntRegister(uiGPIOPort,pfnIntHandler); #endif // // Enable Interrupt // MAP_GPIOIntClear(uiGPIOPort,ucGPIOPin); MAP_GPIOIntEnable(uiGPIOPort,ucGPIOPin); }
STATIC void pin_extint_register(pin_obj_t *self, uint32_t intmode, uint32_t priority) { void *handler; uint32_t intnum; // configure the interrupt type MAP_GPIOIntTypeSet(self->port, self->bit, intmode); switch (self->port) { case GPIOA0_BASE: handler = GPIOA0IntHandler; intnum = INT_GPIOA0; break; case GPIOA1_BASE: handler = GPIOA1IntHandler; intnum = INT_GPIOA1; break; case GPIOA2_BASE: handler = GPIOA2IntHandler; intnum = INT_GPIOA2; break; case GPIOA3_BASE: default: handler = GPIOA3IntHandler; intnum = INT_GPIOA3; break; } MAP_GPIOIntRegister(self->port, handler); // set the interrupt to the lowest priority, to make sure that // no other ISRs will be preemted by this one MAP_IntPrioritySet(intnum, priority); }
STATIC void pin_extint_register(pin_obj_t *self, uint32_t intmode, uint32_t priority) { //void *handler; uint32_t intnum; // configure the interrupt type MAP_GPIOIntTypeSet(self->port, self->bit, intmode); switch (self->port) { case GPIO_PORTA_BASE: intnum = INT_GPIOA_TM4C123; break; case GPIO_PORTB_BASE: intnum = INT_GPIOB_TM4C123; break; case GPIO_PORTC_BASE: intnum = INT_GPIOC_TM4C123; break; case GPIO_PORTD_BASE: intnum = INT_GPIOD_TM4C123; case GPIO_PORTE_BASE: intnum = INT_GPIOE_TM4C123; case GPIO_PORTF_BASE: default: intnum = INT_GPIOF_TM4C123; break; } // set the interrupt to the lowest priority, to make sure that // no other ISRs will be preemted by this one MAP_IntPrioritySet(intnum, priority); }
//! //! \return 0 - Success //! -1 - Error //! //! \brief Initializes Audio Player Push Button Controls // //***************************************************************************** long InitControl(P_AUDIO_HANDLER pAudioInControl,P_AUDIO_HANDLER pAudioOutControl) { long lRetVal = -1; // // Set Interrupt Type for GPIO // MAP_GPIOIntTypeSet(GPIOA1_BASE,GPIO_PIN_5,GPIO_FALLING_EDGE); MAP_GPIOIntTypeSet(GPIOA2_BASE,GPIO_PIN_6,GPIO_FALLING_EDGE); // // Store Interrupt handlers // g_pAudioInControlHdl = pAudioInControl; g_pAudioOutControlHdl = pAudioOutControl; // // Register Interrupt handler // lRetVal = osi_InterruptRegister(INT_GPIOA1,(P_OSI_INTR_ENTRY)MICButtonHandler,\ INT_PRIORITY_LVL_1); ASSERT_ON_ERROR(lRetVal); lRetVal = osi_InterruptRegister(INT_GPIOA2,(P_OSI_INTR_ENTRY) \ SpeakerButtonHandler,INT_PRIORITY_LVL_1); ASSERT_ON_ERROR(lRetVal); // // Enable Interrupt // MAP_GPIOIntClear(GPIOA1_BASE,GPIO_PIN_5); MAP_GPIOIntEnable(GPIOA1_BASE,GPIO_INT_PIN_5); MAP_GPIOIntClear(GPIOA2_BASE,GPIO_PIN_6); MAP_GPIOIntEnable(GPIOA2_BASE,GPIO_INT_PIN_6); return SUCCESS; }
void GPS_init() { dbg_printf("Initializing GPS module..."); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART); MAP_GPIOPinConfigure(GPIO_PA0_U0RX); MAP_GPIOPinConfigure(GPIO_PA1_U0TX); MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); MAP_UARTConfigSetExpClk(UART_BASE, MAP_SysCtlClockGet(), UART_SPEED, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE); MAP_UARTDisable(UART_BASE); MAP_UARTTxIntModeSet(UART_BASE, UART_TXINT_MODE_EOT); MAP_UARTIntEnable(UART_BASE, UART_INT_RX | UART_INT_TX); MAP_IntEnable(INT_UART); MAP_UARTEnable(UART_BASE); MAP_UARTFIFODisable(UART_BASE); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); // MAP_IntEnable(INT_GPIOG); // Настроить прерывания на PPS MAP_GPIOIntTypeSet(GPIO_PORTG_BASE, GPIO_PIN_7, GPIO_FALLING_EDGE); MAP_GPIOPinIntEnable(GPIO_PORTG_BASE, GPIO_PIN_7); // if (tn_task_create(&task_GPS_tcb, &task_GPS_func, TASK_GPS_PRI, &task_GPS_stk[TASK_GPS_STK_SZ - 1], TASK_GPS_STK_SZ, 0, TN_TASK_START_ON_CREATION) != TERR_NO_ERR) { dbg_puts("tn_task_create(&task_GPS_tcb) error"); goto err; } // Настроить прерывания на PPS //MAP_IntEnable(INT_GPIOG); //MAP_GPIOIntTypeSet(GPIO_PORTG_BASE, GPIO_PIN_7, GPIO_FALLING_EDGE); //MAP_GPIOPinIntEnable(GPIO_PORTG_BASE, GPIO_PIN_7); dbg_puts("[done]"); return; err: dbg_trace(); tn_halt(); }
void systick_init() { // // Configure SysTick for a periodic interrupt. // MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / SYSTICKHZ); MAP_SysTickEnable(); MAP_SysTickIntEnable(); //MAP_IntEnable(INT_GPIOA); MAP_IntEnable(INT_GPIOE); MAP_IntMasterEnable(); MAP_SysCtlPeripheralClockGating(false); MAP_GPIOIntTypeSet(GPIO_PORTE_BASE, ENC_INT, GPIO_FALLING_EDGE); MAP_GPIOPinIntClear(GPIO_PORTE_BASE, ENC_INT); MAP_GPIOPinIntEnable(GPIO_PORTE_BASE, ENC_INT); UARTprintf("int enabled\n"); }
void pio_init() { // Board Initialization start // // // The FPU should be enabled because some compilers will use floating- // point registers, even for non-floating-point code. If the FPU is not // enabled this will cause a fault. This also ensures that floating- // point operations could be added to this application and would work // correctly and use the hardware floating-point unit. Finally, lazy // stacking is enabled for interrupt handlers. This allows floating- // point instructions to be used within interrupt handlers, but at the // expense of extra stack usage. // FPUEnable(); FPULazyStackingEnable(); //Init the device with 16 MHz clock. initClk(); /* Configure the system peripheral bus that IRQ & EN pin are map to */ MAP_SysCtlPeripheralEnable( SYSCTL_PERIPH_IRQ_PORT); // // Disable all the interrupts before configuring the lines // MAP_GPIOPinIntDisable(SPI_GPIO_IRQ_BASE, 0xFF); // // Cofigure WLAN_IRQ pin as input // MAP_GPIOPinTypeGPIOInput(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN); GPIOPadConfigSet(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // // Setup the GPIO interrupt for this pin // MAP_GPIOIntTypeSet(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN, GPIO_FALLING_EDGE); // // Configure WLAN chip // MAP_GPIOPinTypeGPIOOutput(SPI_GPIO_IRQ_BASE, SPI_EN_PIN); MAP_GPIODirModeSet( SPI_GPIO_IRQ_BASE, SPI_EN_PIN, GPIO_DIR_MODE_OUT ); MAP_GPIOPadConfigSet( SPI_GPIO_IRQ_BASE, SPI_EN_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD ); MAP_GPIOPinWrite(SPI_GPIO_IRQ_BASE, SPI_EN_PIN, PIN_LOW); SysCtlDelay(600000); SysCtlDelay(600000); SysCtlDelay(600000); // // Disable WLAN CS with pull up Resistor // MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SPI_PORT); MAP_GPIOPinTypeGPIOOutput(SPI_CS_PORT, SPI_CS_PIN); GPIOPadConfigSet(SPI_CS_PORT, SPI_CS_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); MAP_GPIOPinWrite(SPI_CS_PORT, SPI_CS_PIN, PIN_HIGH); // // Enable interrupt for WLAN_IRQ pin // MAP_GPIOPinIntEnable(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN); // // Clear interrupt status // SpiCleanGPIOISR(); MAP_IntEnable(INT_GPIO_SPI); //init LED initLEDs(); }
void main(void) { static struct uip_eth_addr eth_addr; uip_ipaddr_t ipaddr; cpu_init(); uart_init(); printf("Welcome\n"); spi_init(); enc28j60_comm_init(); printf("Welcome\n"); enc_init(mac_addr); // // Configure SysTick for a periodic interrupt. // MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / SYSTICKHZ); MAP_SysTickEnable(); MAP_SysTickIntEnable(); //MAP_IntEnable(INT_GPIOA); MAP_IntEnable(INT_GPIOE); MAP_IntMasterEnable(); MAP_SysCtlPeripheralClockGating(false); printf("int enabled\n"); MAP_GPIOIntTypeSet(GPIO_PORTE_BASE, ENC_INT, GPIO_FALLING_EDGE); MAP_GPIOPinIntClear(GPIO_PORTE_BASE, ENC_INT); MAP_GPIOPinIntEnable(GPIO_PORTE_BASE, ENC_INT); uip_init(); eth_addr.addr[0] = mac_addr[0]; eth_addr.addr[1] = mac_addr[1]; eth_addr.addr[2] = mac_addr[2]; eth_addr.addr[3] = mac_addr[3]; eth_addr.addr[4] = mac_addr[4]; eth_addr.addr[5] = mac_addr[5]; uip_setethaddr(eth_addr); #define DEFAULT_IPADDR0 10 #define DEFAULT_IPADDR1 0 #define DEFAULT_IPADDR2 0 #define DEFAULT_IPADDR3 201 #define DEFAULT_NETMASK0 255 #define DEFAULT_NETMASK1 255 #define DEFAULT_NETMASK2 255 #define DEFAULT_NETMASK3 0 #undef STATIC_IP #ifdef STATIC_IP uip_ipaddr(ipaddr, DEFAULT_IPADDR0, DEFAULT_IPADDR1, DEFAULT_IPADDR2, DEFAULT_IPADDR3); uip_sethostaddr(ipaddr); printf("IP: %d.%d.%d.%d\n", DEFAULT_IPADDR0, DEFAULT_IPADDR1, DEFAULT_IPADDR2, DEFAULT_IPADDR3); uip_ipaddr(ipaddr, DEFAULT_NETMASK0, DEFAULT_NETMASK1, DEFAULT_NETMASK2, DEFAULT_NETMASK3); uip_setnetmask(ipaddr); #else uip_ipaddr(ipaddr, 0, 0, 0, 0); uip_sethostaddr(ipaddr); printf("Waiting for IP address...\n"); uip_ipaddr(ipaddr, 0, 0, 0, 0); uip_setnetmask(ipaddr); #endif httpd_init(); #ifndef STATIC_IP dhcpc_init(mac_addr, 6); dhcpc_request(); #endif long lPeriodicTimer, lARPTimer; lPeriodicTimer = lARPTimer = 0; int i; // = MAP_GPIOPinRead(GPIO_PORTA_BASE, ENC_INT) & ENC_INT; while(true) { //MAP_IntDisable(INT_UART0); MAP_SysCtlSleep(); //MAP_IntEnable(INT_UART0); //i = MAP_GPIOPinRead(GPIO_PORTA_BASE, ENC_INT) & ENC_INT; /*while(i != 0 && g_ulFlags == 0) { i = MAP_GPIOPinRead(GPIO_PORTA_BASE, ENC_INT) & ENC_INT; }*/ if( HWREGBITW(&g_ulFlags, FLAG_ENC_INT) == 1 ) { HWREGBITW(&g_ulFlags, FLAG_ENC_INT) = 0; enc_action(); } if(HWREGBITW(&g_ulFlags, FLAG_SYSTICK) == 1) { HWREGBITW(&g_ulFlags, FLAG_SYSTICK) = 0; lPeriodicTimer += SYSTICKMS; lARPTimer += SYSTICKMS; //printf("%d %d\n", lPeriodicTimer, lARPTimer); } if( lPeriodicTimer > UIP_PERIODIC_TIMER_MS ) { lPeriodicTimer = 0; int l; for(l = 0; l < UIP_CONNS; l++) { uip_periodic(l); // // If the above function invocation resulted in data that // should be sent out on the network, the global variable // uip_len is set to a value > 0. // if(uip_len > 0) { uip_arp_out(); enc_send_packet(uip_buf, uip_len); uip_len = 0; } } for(l = 0; l < UIP_UDP_CONNS; l++) { uip_udp_periodic(l); if( uip_len > 0) { uip_arp_out(); enc_send_packet(uip_buf, uip_len); uip_len = 0; } } } if( lARPTimer > UIP_ARP_TIMER_MS) { lARPTimer = 0; uip_arp_timer(); } } }
//***************************************************************************** // // Initialize the I2C, MPU9150 and Gesture systems. // //***************************************************************************** void MotionInit(void) { // // Enable port S used for motion interrupt. // MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOS); // // The I2C3 peripheral must be enabled before use. // MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); // // Configure the pin muxing for I2C3 functions on port G4 and G5. // MAP_GPIOPinConfigure(GPIO_PG4_I2C3SCL); MAP_GPIOPinConfigure(GPIO_PG5_I2C3SDA); // // Select the I2C function for these pins. This function will also // configure the GPIO pins pins for I2C operation, setting them to // open-drain operation with weak pull-ups. Consult the data sheet // to see which functions are allocated per pin. // MAP_GPIOPinTypeI2CSCL(GPIO_PORTG_BASE, GPIO_PIN_4); MAP_GPIOPinTypeI2C(GPIO_PORTG_BASE, GPIO_PIN_5); // // Configure and Enable the GPIO interrupt. Used for INT signal from the // MPU9150 // MAP_GPIOPinTypeGPIOInput(GPIO_PORTS_BASE, GPIO_PIN_2); MAP_GPIOIntEnable(GPIO_PORTS_BASE, GPIO_PIN_2); MAP_GPIOIntTypeSet(GPIO_PORTS_BASE, GPIO_PIN_2, GPIO_FALLING_EDGE); MAP_IntEnable(INT_GPIOS); // // Enable interrupts to the processor. // MAP_IntMasterEnable(); // // Initialize I2C3 peripheral. // I2CMInit(&g_sI2CInst, I2C3_BASE, INT_I2C3, 0xff, 0xff, g_ui32SysClock); // // Set the motion state to initializing. // g_ui8MotionState = MOTION_STATE_INIT; // // Initialize the MPU9150 Driver. // MPU9150Init(&g_sMPU9150Inst, &g_sI2CInst, MPU9150_I2C_ADDRESS, MotionCallback, &g_sMPU9150Inst); // // Wait for transaction to complete // MotionI2CWait(__FILE__, __LINE__); // // Write application specifice sensor configuration such as filter settings // and sensor range settings. // g_sMPU9150Inst.pui8Data[0] = MPU9150_CONFIG_DLPF_CFG_94_98; g_sMPU9150Inst.pui8Data[1] = MPU9150_GYRO_CONFIG_FS_SEL_250; g_sMPU9150Inst.pui8Data[2] = (MPU9150_ACCEL_CONFIG_ACCEL_HPF_5HZ | MPU9150_ACCEL_CONFIG_AFS_SEL_2G); MPU9150Write(&g_sMPU9150Inst, MPU9150_O_CONFIG, g_sMPU9150Inst.pui8Data, 3, MotionCallback, &g_sMPU9150Inst); // // Wait for transaction to complete // MotionI2CWait(__FILE__, __LINE__); // // Configure the data ready interrupt pin output of the MPU9150. // g_sMPU9150Inst.pui8Data[0] = (MPU9150_INT_PIN_CFG_INT_LEVEL | MPU9150_INT_PIN_CFG_INT_RD_CLEAR | MPU9150_INT_PIN_CFG_LATCH_INT_EN); g_sMPU9150Inst.pui8Data[1] = MPU9150_INT_ENABLE_DATA_RDY_EN; MPU9150Write(&g_sMPU9150Inst, MPU9150_O_INT_PIN_CFG, g_sMPU9150Inst.pui8Data, 2, MotionCallback, &g_sMPU9150Inst); // // Wait for transaction to complete // MotionI2CWait(__FILE__, __LINE__); // // Initialize the DCM system. // CompDCMInit(&g_sCompDCMInst, 1.0f / ((float) MOTION_SAMPLE_FREQ_HZ), DCM_ACCEL_WEIGHT, DCM_GYRO_WEIGHT, DCM_MAG_WEIGHT); // // Initialize the gesture instance and establish a initial state estimate. // GestureInit(&g_sGestureInst, g_pfInitProb, g_ppfPath, g_ppfTransitionProb, g_ppfEmitProb, GESTURE_PATH_LENGTH, GESTURE_NUM_STATES, GESTURE_STATE_IDLE); }
BOOL ds1390_init(void) { //BOOL b_init=false; //unsigned char test; unsigned BOOL time_error = TRUE; DS1390_DATA_BUF ds1390_data_buf; DS1390_TIME ds1390_temp; dbg_printf("Initializing DS1390u..."); g_ds1390_spi_bitrate = DS1390_BITRATE; /* //Пробуем писать и читать for (int i=0; i<10; i++) { ds1390_wr_b(DS1390_REG_ALARM_100THS, 0x5A); if (ds1390_rd_b(DS1390_REG_ALARM_100THS) != 0x5A) { continue; //dbg_puts("[false]"); //return (BOOL)FALSE; } else { b_init = true; break; } } //////// if (!b_init) { dbg_puts("[false]"); return (BOOL)FALSE; } */ ////////// ds1390_rd((unsigned char*)&ds1390_data_buf); /* do { test = ds1390_data_buf.sec; ds1390_rd((unsigned char*)&ds1390_data_buf); } while(test != ds1390_data_buf.sec); */ if (ds1390_data_buf.control & 0x18) { dbg_printf("first start..."); ds1390_wr_b(DS1390_REG_CONTROL, 0x00); time_error = FALSE; } if (ds1390_data_buf.status & 0x80) { dbg_printf("the clock was stoped..."); ds1390_wr_b(DS1390_REG_STATUS, 0x00); // запустим часики time_error = FALSE; } if (time_BCD_to_char(&ds1390_data_buf , &ds1390_temp)) { ds1390_time_true = TRUE; }else { ds1390_time_true = FALSE; time_error = FALSE; } if (!time_error) { dbg_printf("reset time to 1.1.2014-00:00:00..."); ds1390_temp.msec = 0; ds1390_temp.sec = 0; ds1390_temp.min = 0; ds1390_temp.hour = 0; ds1390_temp.date = 1; ds1390_temp.month = 1; ds1390_temp.year = 2014; SetTime_DS1390(&ds1390_temp); } if (ds1390_data_buf.trickle_charger != 0xA9) ds1390_wr_b(DS1390_REG_TRICKLE, 0xA9); // включим подзарядку батарейки // Настроить прерывания на DS1390 MAP_IntEnable(INT_GPIOA); MAP_GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_RISING_EDGE); MAP_GPIOPinIntEnable(GPIO_PORTA_BASE, GPIO_PIN_7); dbg_puts("[done]"); return (BOOL)TRUE; }
/* * initialize tm4c */ void init_satellite() { FPUEnable(); FPULazyStackingEnable(); /* * init clock */ MAP_SysCtlClockSet(SYSCTL_SYSDIV_3 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); //66.6..MHz MAP_IntMasterEnable(); /* * Enable peripherals */ MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //for LED indication MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); //for UART MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //for IRQ and SW_EN MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); //for SPI /* * configure */ MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); MAP_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, SIGNAL_LOW); //off MAP_GPIOPinConfigure(GPIO_PA0_U0RX); MAP_GPIOPinConfigure(GPIO_PA1_U0TX); MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTStdioConfig(UART_PORT, UART_BAUDRATE, SysCtlClockGet()); MAP_GPIOIntDisable(GPIO_PORTB_BASE, SIGNAL_HIGH); //interrupt disable MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_2); //IRQ as input MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); MAP_GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_FALLING_EDGE); //enable interrupt MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5); //sw enable MAP_GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_DIR_MODE_OUT); MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD); MAP_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, SIGNAL_LOW); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); MAP_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0); MAP_GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); MAP_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_0, SIGNAL_HIGH); //chip select MAP_GPIOIntEnable(GPIO_PORTB_BASE, GPIO_PIN_2); //enable interrupt for WLAN_IRQ pin SpiCleanGPIOISR(); //clear interrupt status MAP_IntEnable(INT_GPIOB); //spi init_worker(); setState(READY); }