char* init_bt(void) { pio_init(PIO_BT_CONNECTED); busart0 = busart_init (0, BUSART_BAUD_DIVISOR (115200), tx0buffer, sizeof (tx0buffer), rx0buffer, sizeof (rx0buffer)); return read_bt_string; }
emulator_context* emu_init() { emulator_context* ectx = emu_create_context(0, 0, 0); pio_init(); dev_init_devices(ectx); return ectx; }
//***************************************************************************** // //! initDriver //! //! @param None //! //! @return none //! //! @brief The function initializes a CC3000 device and triggers it to //! start operation // //***************************************************************************** int initDriver(void) { // Init GPIO's pio_init(); //Init Spi init_spi(); DispatcherUARTConfigure(); // WLAN On API Implementation wlan_init( CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin); // Trigger a WLAN device wlan_start(0); // Turn on the LED 5 to indicate that we are active and initiated WLAN successfully turnLedOn(5); // Mask out all non-required events from CC3000 wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT|HCI_EVNT_WLAN_ASYNC_PING_REPORT); // Generate the event to CLI: send a version string { char cc3000IP[50]; char *ccPtr; unsigned short ccLen; DispatcherUartSendPacket((unsigned char*)pucUARTExampleAppString, sizeof(pucUARTExampleAppString)); ccPtr = &cc3000IP[0]; ccLen = my_itoa(PALTFORM_VERSION, ccPtr); ccPtr += ccLen; *ccPtr++ = '.'; ccLen = my_itoa(APPLICATION_VERSION, ccPtr); ccPtr += ccLen; *ccPtr++ = '.'; ccLen = my_itoa(SPI_VERSION_NUMBER, ccPtr); ccPtr += ccLen; *ccPtr++ = '.'; ccLen = my_itoa(DRIVER_VERSION_NUMBER, ccPtr); ccPtr += ccLen; *ccPtr++ = '\f'; *ccPtr++ = '\r'; *ccPtr++ = '\0'; DispatcherUartSendPacket((unsigned char*)cc3000IP, strlen(cc3000IP)); } wakeup_timer_init(); ucStopSmartConfig = 0; return(0); }
static void LoadCommon(MDFNFILE *fp) { try { /* Assign default settings (US NTSC machine) */ sms.display = DISPLAY_NTSC; sms.territory = MDFN_GetSettingI("sms.territory"); sms.use_fm = FALSE; Cart_Init(fp); Cart_LoadNV(); if(IS_SMS && sms.territory == TERRITORY_DOMESTIC) sms.use_fm = MDFN_GetSettingB("sms.fm"); MDFNMP_Init(1024, 65536 / 1024); system_assign_device(PORT_A, DEVICE_PAD2B); system_assign_device(PORT_B, DEVICE_PAD2B); MDFNMP_AddRAM(8192, 0xC000, sms.wram); sms_init(); pio_init(); vdp_init(IS_SMS && sms.territory == TERRITORY_DOMESTIC); render_init(); MDFNGameInfo->GameSetMD5Valid = FALSE; uint32 sndclk; if(sms.display == DISPLAY_PAL) { sndclk = 3546893; MDFNGameInfo->fps = (uint32)((uint64)65536 * 256 * sndclk / 313 / 228); //6144000 * 65536 * 256 / 515 / 198); // 3072000 * 2 * 10000 / 515 / 198 } else { sndclk = 3579545; MDFNGameInfo->fps = (uint32)((uint64)65536 * 256 * sndclk / 262 / 228); //6144000 * 65536 * 256 / 515 / 198); // 3072000 * 2 * 10000 / 515 / 198 } MDFNGameInfo->MasterClock = MDFN_MASTERCLOCK_FIXED(sndclk); SMS_SoundInit(sndclk, sms.use_fm); sms.save = 0; system_reset(); } catch(...) { Cleanup(); throw; } }
void init_pins( void ) { pio_config_set (PIO_LED_R, PIO_OUTPUT_LOW); pio_config_set (PIO_LED_Y, PIO_OUTPUT_LOW); pio_config_set (PIO_LED_G, PIO_OUTPUT_LOW); pio_config_set (PIO_H_1, PIO_OUTPUT_LOW); pio_config_set (PIO_H_2, PIO_OUTPUT_LOW); pio_config_set (PIO_H_3, PIO_OUTPUT_LOW); pio_config_set (PIO_H_4, PIO_OUTPUT_LOW); pio_config_set (PIO_DIP_1, PIO_PULLUP); pio_init(PIO_DIP_1); pio_config_set (PIO_DIP_2, PIO_PULLUP); pio_init(PIO_DIP_2); pio_config_set (PIO_DIP_3, PIO_PULLUP); pio_init(PIO_DIP_3); pio_config_set (PIO_DIP_4, PIO_PULLUP); pio_init(PIO_DIP_4); pio_config_set (PIO_SW_SLEEP, PIO_PULLUP); pio_init(PIO_SW_SLEEP); pio_config_set (PIO_AUX_ENABLE, PIO_OUTPUT_HIGH); }
void system_init(void) { sms_init(); pio_init(); vdp_init(); render_init(); sound_init(); sms.save = 0; }
static inline ALWAYS_INLINE void THREAD_LOCK(int fd) { if G_UNLIKELY(!pio_inited) pio_init(); g_assert(fd >= 0); g_assert(UNSIGNED(fd) < pio_capacity); spinlock_hidden(&pio_locks[fd]); }
//***************************************************************************** // //! initDriver //! //! \param None //! //! \return none //! //! \brief The function initializes a CC3000 device and triggers it to start operation // //***************************************************************************** int initDriver(void) { pio_init(); // Init GPIO's init_spi(); wlan_init( CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin); wlan_start(0); if (IP_ALLOC_METHOD == USE_STATIC_IP){// The DHCP setting shave been removed. pucSubnetMask[0] = 0xFF;// Subnet mask is assumed to be 255.255.255.0 pucSubnetMask[1] = 0xFF; pucSubnetMask[2] = 0xFF; pucSubnetMask[3] = 0x0; pucIP_Addr[0] = STATIC_IP_OCT1; // CC3000's IP pucIP_Addr[1] = STATIC_IP_OCT2; pucIP_Addr[2] = STATIC_IP_OCT3; pucIP_Addr[3] = STATIC_IP_OCT4; pucIP_DefaultGWAddr[0] = STATIC_IP_OCT1;// Default Gateway/Router IP pucIP_DefaultGWAddr[1] = STATIC_IP_OCT2; pucIP_DefaultGWAddr[2] = STATIC_IP_OCT3; pucIP_DefaultGWAddr[3] = 1; pucDNS[0] = STATIC_IP_OCT1;// We assume the router is also a DNS server pucDNS[1] = STATIC_IP_OCT2; pucDNS[2] = STATIC_IP_OCT3; pucDNS[3] = 1; netapp_dhcp((unsigned long *)pucIP_Addr, (unsigned long *)pucSubnetMask, (unsigned long *)pucIP_DefaultGWAddr, (unsigned long *)pucDNS); // reset the CC3000 to apply Static Setting wlan_stop(); __delay_cycles(6000000); wlan_start(0); } // Mask out all non-required events from CC3000 wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_ASYNC_PING_REPORT); unsolicicted_events_timer_init(); // CC3000 has been initialized setCC3000MachineState(CC3000_INIT); return(0); }
void irInit(void) { pio_config_set (PA26_PIO, PIO_INPUT); pio_init(PA26_PIO); tc = tc_init (&tc_cfg); if (!tc) { /* This will fail for an invalid choice of PIO for tc. */ while (1) continue; } tc_start (tc); prev_time = tc_counter_get (tc); irInterruptInit(); }
void adc_init() { pio_init(); spi_init(); //nSYNC/nPD pio_set_output(ADC_nSYNC,0,FALSE,FALSE); //ADC_nDRDY pio_set_input(ADC_nDRDY0,FALSE,FALSE); pio_set_input(ADC_nDRDY1,FALSE,FALSE); pio_set_input(ADC_nDRDY2,FALSE,FALSE); gAdcDesc.state=ADC_IDLE; #if PWM_DEBUG pwm_init(); #endif }
static void magic_online(const u08 *buf) { uart_send_time_stamp_spc(); uart_send_pstring(PSTR("[MAGIC] online\r\n")); flags |= FLAG_ONLINE | FLAG_FIRST_TRANSFER; // validate mac address and if it does not match then reconfigure PIO const u08 *src_mac = eth_get_src_mac(buf); if(!net_compare_mac(param.mac_addr, src_mac)) { // update mac param and save net_copy_mac(src_mac, param.mac_addr); param_save(); // re-configure PIO pio_exit(); pio_init(param.mac_addr, PIO_INIT_BROAD_CAST); } }
void dash_io_init() { // Husk WPEN bit for å kunne skrive til OER etc .. side 737 ( Disabled by default) pio_init(); // Enables peripheral clock and enables IRQ for all pio registers pio_enableOutput(FT800_POWERDOWN_PIO,FT800_POWERDOWN_PIN); pio_setOutput(FT800_POWERDOWN_PIO,FT800_POWERDOWN_PIN, PIN_HIGH); pio_inputDebounce(NAVIGATION_L_PIO,NAVIGATION_L_PIN,653,DEBOUNCE); // Needs periph clk for filter pio_inputDebounce(NAVIGATION_R_PIO,NAVIGATION_R_PIN,653,DEBOUNCE); pio_inputDebounce(NAVIGATION_D_PIO,NAVIGATION_D_PIN,653,DEBOUNCE); pio_inputDebounce(NAVIGATION_U_PIO,NAVIGATION_U_PIN,653,DEBOUNCE); pio_inputDebounce(NAV_ACK_PIO,NAV_ACK_PIN,653,DEBOUNCE); pio_inputDebounce(START_PIO,START_PIN,653,DEBOUNCE); pio_inputDebounce(ROT_PUSH3_PIO,ROT_PUSH3_PIN,653,DEBOUNCE); pio_disableOutput(ROT_A_PIO,ROT_A_PIN); pio_disableOutput(ROT_B_PIO,ROT_B_PIN); pio_outputPulldownLow(BUZZER_PIO,BUZZER_PIN); pio_inputPulldown(DETECT_USB_PIO,DETECT_USB_PIN,PULLDOWN); pio_inputDebounce(DETECT_USB_PIO,DETECT_USB_PIN,3000,DEBOUNCE); // LEDS pio_outputPulldownLow(IMD_LED_PIO,IMD_LED_PIN); pio_outputPulldownLow(AMS_LED_PIO,AMS_LED_PIN); pio_outputPulldownLow(ECU_LED_PIO,ECU_LED_PIN); pio_outputPulldownLow(DEVICE_LED_PIO,DEVICE_LED_PIN); pio_outputPulldownLow(TEMP_LED_PIO,TEMP_LED_PIN); pio_outputPulldownLow(TS_LED_PIO,TS_LED_PIN); pio_outputPulldownLow(LC_LED_PIO,LC_LED_PIN); pio_outputPulldownLow(VOLT_LED_PIO,VOLT_LED_PIN); //Interrupts on rotary //pio_enableInterrupt(ROT_B_PIO,ROT_B_PIN, RISING_EDGE,rotaryEncoderInterruptFunction); //pio_enableInterrupt(ROT_B_PIO,ROT_B_PIN, FALLING_EDGE,rotaryEncoderInterruptFunction); //PIOB->PIO_ISR; }
//***************************************************************************** // //! board_init //! //! \param none //! //! \return none //! //! \brief Initialize the board's interfaces // //***************************************************************************** void board_init() { // Stop WDT WDTCTL = WDTPW + WDTHOLD; // Init GPIO's pio_init(); // Setup sensors hooked up to the board (if any) setupSensors(); // Start CC3000 State Machine resetCC3000StateMachine(); // Initialize Board and CC3000 initDriver(); // Initialize CC3000 Unsolicited Events Timer unsolicicted_events_timer_init(); // Enable interrupts __enable_interrupt(); }
/** Create a new button object. @param cfg pointer to button configuration @return pointer to button object */ button_t button_init (const button_cfg_t *cfg) { button_dev_t *button; if (button_num >= BUTTON_NUM) return 0; button = &buttons[button_num++]; button->pio = cfg->pio; button->state = BUTTON_STATE_UP; button->count = 0; button->hold_count = 0; /* Ensure PIO clock enabled for PIO reading. */ pio_init (cfg->pio); /* Configure pio for input and enable internal pullup resistor. */ pio_config_set (cfg->pio, PIO_PULLUP); return button; }
//***************************************************************************** // //! initDriver //! //! \param[in] cRequestPatch 0 to load with EEPROM patches and 1 to load with no patches //! //! \return none //! //! \brief The function initializes a CC3000 device and triggers it to start operation // //***************************************************************************** int initDriver(unsigned short cRequestPatch) { // // Init GPIO's // pio_init(); // //init all layers // init_spi(); // // WLAN On API Implementation // wlan_init( CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin); // // Trigger a WLAN device // wlan_start(cRequestPatch); wlan_smart_config_set_prefix(aucCC3000_prefix); // Turn on the LED 5 to indicate that we are active and initiated WLAN successfully turnLedOn(5); // // Mask out all non-required events from CC3000 // wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT|HCI_EVNT_WLAN_ASYNC_PING_REPORT); unsolicicted_events_timer_init(); return(0); }
//***************************************************************************** // //! initDriver //! //! @param None //! //! @return none //! //! @brief The function initializes a CC3000 device and triggers it to start //! operation // //***************************************************************************** int initDriver(void) { // Init GPIO's pio_init(); // Init Spi init_spi(); // Enable processor interrupts MAP_IntMasterEnable(); // WLAN On API Implementation wlan_init( CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin); // Trigger a WLAN device wlan_start(0); // Turn on the LED 1 (RED) to indicate that we are active and initiated WLAN successfully turnLedOn(1); // Mask out all non-required events from CC3000 wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT |HCI_EVNT_WLAN_ASYNC_PING_REPORT); DispatcherUARTConfigure(SysCtlClockGet()); SysCtlDelay(1000000); // Generate teh event to CLI: send a version string { char cc3000IP[50]; char *ccPtr; unsigned short ccLen; DispatcherUartSendPacket((unsigned char*)pucUARTExampleAppString, sizeof(pucUARTExampleAppString)); ccPtr = &cc3000IP[0]; ccLen = itoa(PALTFORM_VERSION, ccPtr); ccPtr += ccLen; *ccPtr++ = '.'; ccLen = itoa(APPLICATION_VERSION, ccPtr); ccPtr += ccLen; *ccPtr++ = '.'; ccLen = itoa(SPI_VERSION_NUMBER, ccPtr); ccPtr += ccLen; *ccPtr++ = '.'; ccLen = itoa(DRIVER_VERSION_NUMBER, ccPtr); ccPtr += ccLen; *ccPtr++ = '\f'; *ccPtr++ = '\r'; *ccPtr++ = '\0'; DispatcherUartSendPacket((unsigned char*)cc3000IP, strlen(cc3000IP)); } ucStopSmartConfig = 0; // Configure SysTick to occur X times per second, to use as a time // reference. Enable SysTick to generate interrupts. InitSysTick(); return(0); }
u08 bridge_loop(void) { u08 result = CMD_WORKER_IDLE; uart_send_time_stamp_spc(); uart_send_pstring(PSTR("[BRIDGE] on\r\n")); pb_proto_init(fill_pkt, proc_pkt, pkt_buf, PKT_BUF_SIZE); pio_init(param.mac_addr, pio_util_get_init_flags()); stats_reset(); // online flag flags = 0; req_is_pending = 0; u08 flow_control = param.flow_ctl; u08 limit_flow = 0; u08 first = 1; while(run_mode == RUN_MODE_BRIDGE) { // handle commands result = cmd_worker(); if(result & CMD_WORKER_RESET) { break; } // handle pbproto pb_util_handle(); // incoming packet via PIO available? u08 n = pio_has_recv(); if(n>0) { // show first incoming packet if(first) { first = 0; uart_send_time_stamp_spc(); uart_send_pstring(PSTR("FIRST INCOMING!\r\n")); } // if we are online then request the packet receiption if(flags & FLAG_ONLINE) { // if no request is pending then request it trigger_request(); } // offline: get and drop pio packet else { u16 size; pio_util_recv_packet(&size); uart_send_time_stamp_spc(); uart_send_pstring(PSTR("OFFLINE DROP: ")); uart_send_hex_word(size); uart_send_crlf(); } } // flow control if(flow_control) { // flow limited if(limit_flow) { // disable again? if(n==0) { pio_control(PIO_CONTROL_FLOW, 0); limit_flow = 0; if(global_verbose) { uart_send_time_stamp_spc(); uart_send_pstring(PSTR("FLOW off\r\n")); } } } // no flow limit else { // enable? if(n>1) { pio_control(PIO_CONTROL_FLOW, 1); limit_flow = 1; if(global_verbose) { uart_send_time_stamp_spc(); uart_send_pstring(PSTR("FLOW on\r\n")); } } } } } stats_dump_all(); pio_exit(); uart_send_time_stamp_spc(); uart_send_pstring(PSTR("[BRIDGE] off\r\n")); return result; }
static int LoadCommon(MDFNFILE *fp) { int32 size = fp->size; const uint8 *data_ptr = fp->data; if(size & 512) { size -= 512; data_ptr += 512; } /* Assign default settings (US NTSC machine) */ sms.display = DISPLAY_NTSC; sms.territory = MDFN_GetSettingI("sms.territory"); sms.use_fm = FALSE; if(!SMS_CartInit(data_ptr, size)) return(0); if(IS_SMS && sms.territory == TERRITORY_DOMESTIC) sms.use_fm = MDFN_GetSettingB("sms.fm"); MDFNMP_Init(1024, 65536 / 1024); system_assign_device(PORT_A, DEVICE_PAD2B); system_assign_device(PORT_B, DEVICE_PAD2B); MDFNMP_AddRAM(8192, 0xC000, sms.wram); sms_init(); pio_init(); vdp_init(IS_SMS && sms.territory == TERRITORY_DOMESTIC); render_init(); MDFNGameInfo->GameSetMD5Valid = FALSE; uint32 sndclk; if(sms.display == DISPLAY_PAL) { sndclk = 3546893; MDFNGameInfo->fps = (uint32)((uint64)65536 * 256 * sndclk / 313 / 228); //6144000 * 65536 * 256 / 515 / 198); // 3072000 * 2 * 10000 / 515 / 198 } else { sndclk = 3579545; MDFNGameInfo->fps = (uint32)((uint64)65536 * 256 * sndclk / 262 / 228); //6144000 * 65536 * 256 / 515 / 198); // 3072000 * 2 * 10000 / 515 / 198 } MDFNGameInfo->MasterClock = MDFN_MASTERCLOCK_FIXED(sndclk); SMS_SoundInit(sndclk, sms.use_fm); sms.save = 0; system_reset(); return(1); }
//***************************************************************************** // //! initDriver //! //! \param None //! //! \return none //! //! \brief The function initializes a CC3000 device and triggers it to start operation // //***************************************************************************** int initDriver(void) { // Init GPIO's pio_init(); // Init SPI init_spi(); DispatcherUARTConfigure(); // Globally enable interrupts __enable_interrupt(); // // WLAN On API Implementation // wlan_init( CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin); // // Trigger a WLAN device // wlan_start(0); // // Mask out all non-required events from CC3000 // wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_ASYNC_PING_REPORT|HCI_EVNT_WLAN_UNSOL_INIT); // Generate event to CLI: send a version string char cc3000IP[50]; char *ccPtr; unsigned short ccLen; DispatcherUartSendPacket((unsigned char*)pucUARTExampleAppString, sizeof(pucUARTExampleAppString)); ccPtr = &cc3000IP[0]; ccLen = itoa(PALTFORM_VERSION, ccPtr); ccPtr += ccLen; *ccPtr++ = '.'; ccLen = itoa(APPLICATION_VERSION, ccPtr); ccPtr += ccLen; *ccPtr++ = '.'; ccLen = itoa(SPI_VERSION_NUMBER, ccPtr); ccPtr += ccLen; *ccPtr++ = '.'; ccLen = itoa(DRIVER_VERSION_NUMBER, ccPtr); ccPtr += ccLen; *ccPtr++ = '\r'; *ccPtr++ = '\n'; *ccPtr++ = '\0'; ccLen = strlen(cc3000IP); DispatcherUartSendPacket((unsigned char*)cc3000IP, strlen(cc3000IP)); // CC3000 has been initialized setCC3000MachineState(CC3000_INIT); unsigned long aucDHCP, aucARP, aucKeepalive, aucInactivity; aucDHCP = 14400; aucARP = 3600; aucKeepalive = 10; aucInactivity = 50; if(netapp_timeout_values(&(aucDHCP), &(aucARP), &(aucKeepalive), &(aucInactivity)) != 0) { while(1); } return(0); }