void InterlockToggle () { uint8_t tmp = TM_BKPSRAM_Read8(0xF00); if (tmp==0xEB) { TM_BKPSRAM_Write8(0xF00,0x00); TM_BKPSRAM_Write8(1000,0xFA); printf("Interlock is now DISABLED\n\r"); } else { TM_BKPSRAM_Write8(0xF00,0xEB); TM_BKPSRAM_Write8(1000,0x02); printf("Interlock in now ENABLED\n\r"); } }
void gsm(void) { char msg[20]; char number[13]; number[12]=0; config(GC_LOAD,&number,GC_PHONE); sprintf(msg,"Off%d",TM_BKPSRAM_Read8(0)); GSM_Init(); for (int i=0;i<10;i++) { GSM_checkNetwork_Simple(15000); if (GSM_isRegistered()) break; } printf("Successfully registered into GMS network\n"); if(GSM_isRegistered()) GSM_sendSMS(number,msg); dev_control(dev_gsm,dev_off); TM_BKPSRAM_Write8(1000,2); }
/** * In this function, the hardware should be initialized. * Called from ethernetif_init(). * * @param netif the already initialized lwip network interface structure * for this ethernetif */ static void low_level_init(struct netif *netif) { #ifdef CHECKSUM_BY_HARDWARE int i; #endif /* set MAC hardware address length */ netif->hwaddr_len = ETHARP_HWADDR_LEN; /* set MAC hardware address */ #if defined(MAC_ADDR0) && defined(MAC_ADDR1) && defined(MAC_ADDR2) && defined(MAC_ADDR3) && defined(MAC_ADDR4) && defined(MAC_ADDR5) netif->hwaddr[0] = MAC_ADDR0; netif->hwaddr[1] = MAC_ADDR1; netif->hwaddr[2] = MAC_ADDR2; netif->hwaddr[3] = MAC_ADDR3; netif->hwaddr[4] = MAC_ADDR4; netif->hwaddr[5] = MAC_ADDR5; #warning "User defined MAC is used for MAC address settings. Address is defined as in main.h file" #endif #if !defined(MAC_ADDR0) || !defined(MAC_ADDR1) || !defined(MAC_ADDR2) || !defined(MAC_ADDR3) || !defined(MAC_ADDR4) || !defined(MAC_ADDR5) netif->hwaddr[0] = TM_ID_GetUnique8(0); netif->hwaddr[1] = TM_ID_GetUnique8(1); netif->hwaddr[2] = TM_ID_GetUnique8(2); netif->hwaddr[3] = TM_ID_GetUnique8(3); netif->hwaddr[4] = TM_ID_GetUnique8(4); netif->hwaddr[5] = TM_ID_GetUnique8(5); #warning "Custom MAC address not defined in main.h file. Using unique STM32F4 ID as MAC address" #endif /* define below may not be needed because we can set mac based on unique ID written in STM32F4 processor */ #ifdef CUSTOM_MAC // TODO: add checking for correct mac set, if no custom mac is set use default mac set in main.h TM_BKPSRAM_Init(); netif->hwaddr[0] = TM_BKPSRAM_Read8(1); netif->hwaddr[1] = TM_BKPSRAM_Read8(2); netif->hwaddr[2] = TM_BKPSRAM_Read8(3); netif->hwaddr[3] = TM_ID_GetUnique32(0); netif->hwaddr[4] = TM_ID_GetUnique32(1); netif->hwaddr[5] = TM_ID_GetUnique32(2); #endif /* initialize MAC address in ethernet MAC */ ETH_MACAddressConfig(ETH_MAC_Address0, netif->hwaddr); /* maximum transfer unit */ netif->mtu = 1500; /* device capabilities */ /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; /* Initialize Tx Descriptors list: Chain Mode */ ETH_DMATxDescChainInit(DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB); /* Initialize Rx Descriptors list: Chain Mode */ ETH_DMARxDescChainInit(DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB); #ifdef CHECKSUM_BY_HARDWARE /* Enable the TCP, UDP and ICMP checksum insertion for the Tx frames */ for(i=0; i<ETH_TXBUFNB; i++) { ETH_DMATxDescChecksumInsertionConfig(&DMATxDscrTab[i], ETH_DMATxDesc_ChecksumTCPUDPICMPFull); } #endif /* Note: TCP, UDP, ICMP checksum checking for received frame are enabled in DMA config */ /* Enable MAC and DMA transmission and reception */ ETH_Start(); }