static void DemoGetVersion(NWCONN_HANDLE conn) { NWCCODE err; InitBuff(); rqbuff[2] = 12; printf("GetTimeVersion:\n"); err = MyNWRequest(conn, 114, 1, rq, 1, rp); if (err) { fprintf(stderr, "NCP 114.12 failed with %s\n", strnwerror(err)); return; } printf("Returned data length (at least 4): %u\n", rp->fragSize); printf("Version: 0x%08X (%u)\n", *(u_int32_t*)rpbuff, *(u_int32_t*)rpbuff); }
uint32_t SystemInit(void) { uint32_t result; uint32_t unixTime; SetRebootFlag(); LedInit(); //DisplayStart(); RTC_WDT_Init(); InitNetwork(); GateInit(); InitBuff(); BattADC_Init(); /* Enable global interrupts */ CyGlobalIntEnable; /*sync real time*/ unixTime = DS1307_GetUnixTime(); // unixTime = 1485184625 ; if(unixTime > 0) { RTC_SetUnixTime(unixTime); result = DataBaseStart(); if(result == DB_NO_ERROR) { Display("System init..."); result = NO_ERROR; } else { Display("Please insert SD"); result = ERROR; SendFinStatus(FIN_NO_READY); MyDelay(300); } } else { Display("Error sync time"); result = ERROR; SendFinStatus(FIN_NO_READY); MyDelay(500); } return result; }
static void DemoGetGarbage(NWCONN_HANDLE conn) { NWCCODE err; size_t i; InitBuff(); rqbuff[2] = 6; printf("GetTimeGarbage:\n"); err = MyNWRequest(conn, 114, 1, rq, 1, rp); if (err) { fprintf(stderr, "NCP 114.6 failed with %s\n", strnwerror(err)); return; } printf("Returned data length: %u\n", rp->fragSize); printf("Data: "); for (i = 0; i < rp->fragSize; i++) printf(" %02X", rpbuff[i]); printf("\n"); }
static void DemoGetTime(NWCONN_HANDLE conn) { NWCCODE err; InitBuff(); rqbuff[2] = 1; printf("GetUTCTime:\n"); err = MyNWRequest(conn, 114, 1, rq, 1, rp); if (err) { fprintf(stderr, "NCP 114.1 failed with %s\n", strnwerror(err)); return; } printf("Returned data length (at least 28): %u\n", rp->fragSize); printf("Seconds: %u\n", *(u_int32_t*)rpbuff); printf("Fractions: 0x%08X (%u)\n", *(u_int32_t*)(rpbuff + 4), *(u_int32_t*)(rpbuff + 4)); printf("Flags: 0x%08X\n", *(u_int32_t*)(rpbuff + 8)); printf("An event stamps: %08X %08X %08X %08X\n", *(u_int32_t*)(rpbuff + 12), *(u_int32_t*)(rpbuff + 16), *(u_int32_t*)(rpbuff + 20), *(u_int32_t*)(rpbuff + 24)); }
void main ( void ) { ADI_ETHER_HANDLE hEthernet; ADI_ETHER_RESULT etherResult; ADI_ETHER_DEV_INIT EtherInitData[MAX_NETWORK_IF] = { { true, &memtable[0] }, { true, &memtable[1] }}; // data-cache,driver memory uint32_t reg_data; int i, nEtherDevUsed; char *ether_stack_block; ADI_GPIO_RESULT gpio_result; uint32_t gpioMaxCallbacks; int nRet; /** * Initialize managed drivers and/or services that have been added to * the project. * @return zero on success */ adi_initComponents(); /** * The default startup code does not include any functionality to allow * core 0 to enable core 1. A convenient way to enable core 1 is to use the * 'adi_core_1_enable' function. */ adi_core_1_enable(); /* Begin adding your custom code here */ g_AuxiTMIsFirstUpdated = 1; /* init CGU first time */ CGU_Init ( MULTIPLIER_SEL, CCLK_SEL, DDRCLK_SEL ); /* CCLK=16.384*iMultiplier /1 Mhz, 16.384*iMultiplier/iDDCLKSel Mhz DDR2 CLK */ #if defined(__DEBUG_FILE__) /* open the debug file */ pDebugFile = fopen(__DEBUG_FILE_NAME__, "w"); if (pDebugFile == 0) { fclose(pDebugFile); return; } #elif defined(__DEBUG_UART__) Init_UART(); #endif Init_PTPAuxin(); /* configures the switches */ #if BF609_EZ_BRD DEBUG_STATEMENT ( "Configuring switches for the ethernet operation \n\n" ); ConfigSoftSwitches(); #endif /* open ethernet device */ nEtherDevUsed = ( user_net_num_ifces > MAX_NETWORK_IF ) ? MAX_NETWORK_IF : user_net_num_ifces; #if BF609_EZ_BRD nEtherDevUsed = 1; #endif DEBUG_STATEMENT ( " init EMAC\n\n" ); for ( i = 0; i < nEtherDevUsed; i++ ) { etherResult = adi_ether_Open ( g_pDevEntry[i], &EtherInitData[i], g_pEthCallBack[i], &hEthernet ); if ( etherResult != ADI_ETHER_RESULT_SUCCESS ) { DEBUG_STATEMENT ( "adi_ether_Open: failed to open ethernet driver\n\n" ); return ; } g_hDev[i] = hEthernet; /* get the mac address */ memcpy ( ( ( ADI_EMAC_DEVICE * ) hEthernet )->MacAddress, user_net_config_info[i].hwaddr, 6 ); /* allocate memory */ ether_stack_block = heap_malloc ( i+1, g_contEthHeapSize[i] ); if ( ether_stack_block == NULL ) { DEBUG_PRINT ( " heap_malloc: in heap %d, failed to allocate memory to the stack \n\n" , i+1); return ; } /* init buf mem */ nRet = InitBuff ( g_contEthHeapSize[i], ether_stack_block, hEthernet, &user_net_config_info[i] ); if( nRet<0 ) { DEBUG_STATEMENT ( " InitBuff: failed to enable Init Buffs\n\n" ); return ; } /* Enable the MAC */ etherResult = adi_ether_EnableMAC ( hEthernet ); if ( etherResult != ADI_ETHER_RESULT_SUCCESS ) { DEBUG_STATEMENT ( " adi_ether_EnableMAC: failed to enable EMAC\n\n" ); return ; } } //enable EMAC INT adi_int_EnableInt ( ( (ADI_EMAC_DEVICE *)g_hDev[0])->Interrupt, true); adi_int_EnableInt ( ( (ADI_EMAC_DEVICE *)g_hDev[1])->Interrupt, true); /* activate rx channel DMA */ enable_rx ( g_hDev[0] ); enable_rx ( g_hDev[1] ); /* activate tx channel DMA */ enable_tx ( g_hDev[0] ); enable_tx ( g_hDev[1] ); //enable emac0 tx,rx enable_emac_tx_rx ( g_hDev[0] ); //enable emac1 tx,rx enable_emac_tx_rx ( g_hDev[1] ); //enable Enable_Time_Stamp_Auxin_Interrupt(); // HandleLoop(); return ; }//main