/* driver ioctl handler */
static int ethernetIoctl(struct ifnet *ifp, ioctl_command_t command,
                         caddr_t data) {
  int result;
  struct bfin_ethernetSoftc *sc = ifp->if_softc;

  result = 0;
  switch (command) {
  case SIOCGIFADDR:
  case SIOCSIFADDR:
    ether_ioctl(ifp, command, data);
    break;
  case SIOCSIFFLAGS:
    switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) {
    case IFF_RUNNING:
      ethernetStop(sc);
      break;
    case IFF_UP:
      ethernetInit(sc);
      break;
    case IFF_UP | IFF_RUNNING:
      ethernetStop(sc);
      ethernetInit(sc);
      break;
    default:
      break;
    }
    break;
  case SIO_RTEMS_SHOW_STATS:
    bfin_ethernetStats(sc);
    break;
  case SIOCADDMULTI:
  case SIOCDELMULTI:
  default:
    result = EINVAL;
    break;
  }

  return result;
}
Esempio n. 2
0
void init( void )
{
	int i ;
        
	enableUART(0,115200);
	enableUART(1,115200);

	usbll_init();
        messageRxInit();
	framInit(); // must come before ethernet
	ethernetInit();
	samba_init();

	setUsbCallback(USBAPP_ETHERNET,ethernetUsbRx);

	while(1){
		setLED(i++ >> 10);
		
		usbll_poll();
	}
}
Esempio n. 3
0
// ****************  Boucle principale de l'OS ******************************
// Boucle infinie qui attend des ?v?nement li?s aux interruptions pour
// appeler les fonctions enregistr?es
// *************************************************************************
void TIOSStart()
{
    unsigned char idx;
    char j;

    for(j=0; j<14; j++)
    {
        TabRecuRFID[j] = 0;
        iRec = 0;
    }
    FlagLecture = 0;

    //VARAIBLES LOCALES
    //CONFIG PIC
    OSCCONbits.IRCF = 0b111;	// on defini la frequence de l'oscillateur ? 16 mHz
    //CONFIG PIN
            //SELECTION AN/DI		(ANSEL)
    ANSELA = NUM;		//on place toutes les pins en num?rique, XC8 se fout des pins qu'on ne peut pas d?finir
    ANSELB = NUM;
    ANSELC = NUM;
    ANSELD = NUM;
    ANSELE = NUM;
    ANSELDbits.ANSD4 = ANA;     //photodiode
            //SELECTION IN/OUT		(TRIS)
    TRISCbits.TRISC2 = OUT;     //LED en output
    TRISBbits.TRISB4 = OUT;     //RELAIS en output
    TRISDbits.TRISD4 = IN;      //photo diode en input
            //ETAT REPOS DES PINS 	(PORT)
    IO_LED = OFF;
    IO_REL = OFF;
    //Initialisation des périphériques
        //LCD
    initLCD();
        //Boutons
    initBout();
        //RFID
    initRFID();
        //ETHERNET
    ethernetInit();
        //Lumiere ADC
    InitADC();
        //USART
    //initUsart();
    
    INTCONbits.GIE = 1;
    INTCONbits.PEIE = 1;
    RCONbits.IPEN = 1;


    //Cr?ation, configuration et démarrage de Timer1 pour g?n?rer une interruption toutes les mS en priorité haute
    TIMER1_Init_1ms(); //A partir d'ici, interruption toutes les ms par Timer1


    //Boucle principale de l'OS d'o? on ne sort jamais
    while(1)
    {
        ethernetEnvoi();
        Delay10KTCYx(50);
        if(flagusart == 1){
            CBUSARTRECEPT(caractere);
            flagusart = 0;
            compteurUsart=0;
        }
        // Check les conditions pour rappeler les fonctions li?es au temps
        for (idx = 0; idx < MAXCALLBACKCHRONO; idx++)
        {
            if (MaCB[idx]) //Si on a l'adresse d'une fonction CB ? cet index
            //Si on est arriv? au nombre de mS demand?, on appelle la fonction
                if (TickCB[idx] >= TempsCB[idx])
                {
                     TickCB[idx] = 0;
                     MaCB[idx]();  //Rappel de la fonction enregistrée!
                }
        }
        if(flagBout)
        {
            CBBT(bout);
            flagBout = 0;
        }
        if(FlagLecture)
        {
            if(iRec >= 9)          //si on a tout recu
            {
                if(TabRecuRFID[7] == 0xFF)  //si la lecture c'est bien passer
                {
                    CBRFID(TabRecuRFID[3], TabRecuRFID[4], TabRecuRFID[5], TabRecuRFID[6]);
                    for(j=0; j<14; j++)
                    {
                        TabRecuRFID[j] = 0;
                        iRec = 0;
                    }
                    FlagLecture = 0;
                }
                else
                {
                    CBRFID(0,0,0,0);
                    FlagLecture = 0;
                    for(j=0; j<14; j++)
                    {
                        TabRecuRFID[j] = 0;
                        iRec = 0;
                    }
                }
            }
        }
        if(FlagEcriture)
        {
            if(iRec >= 5)
            {
                if(TabRecuRFID[3] == 0xFF)
                {
                    SetDDRamAddr(0x40);
                    while(BusyXLCD());
                    putrsXLCD("                ");
                    while(BusyXLCD());
                    SetDDRamAddr(0x40);
                    while(BusyXLCD());
                    putrsXLCD("Ecriture OK");
                    for(j=0; j<14; j++)
                    {
                        TabRecuRFID[j] = 0;
                        iRec = 0;
                    }
                }
            }
            
            FlagEcriture = 0;
        }
        //Delay10KTCYx(200);
     }
}
void setup() {
  Serial.begin(9600);
  Serial.println();
  Serial.print(SELF_NAME);
  Serial.println(F(" started..."));

  #ifdef ETHERNET_FEATURE
    ethernetInit();
  #endif

  sdCardInit();

  #ifdef RTC_FEATURE
    rtcInit();
  #endif

  #ifdef SERVER_FEATURE
    serverInit();
  #endif

  timersInit();

  #ifdef MAJORDOMO_FEATURE
    majordomoInit();
    majordomoMegaLive();
  #endif

  #ifdef LAURENT_FEATURE
    laurentInit();
  #endif

  #ifdef SD_INFO_FEATURE
    sdInfoInit();
  #endif

  #ifdef SD_FILES_FEATURE
    sdFilesInit();
  #endif

  #ifdef PING_FEATURE
    pingInit();
  #endif

  #ifdef UPLOAD_FEATURE
    uploadInit();
  #endif

  #ifdef PIRS_FEATURE
    pirsInit();
  #endif

  #ifdef CONTACTS_FEATURE
    contactsInit();
  #endif

  #ifdef TEMP_FEATURE
    tempInit();
  #endif

  #ifdef ELECTRO_FEATURE
    electroInit();
  #endif

  #ifdef KEYS_FEATURE
    keysInit();
  #endif

  #ifdef LEDS_FEATURE
    ledsInit();
  #endif

  #ifdef NOO_FEATURE
    nooInit();
  #endif

  timeStamp();
  Serialprint("GLOBAL Init DONE\n");
  Serial.println();
  timeStamp();
  Serialprint("AMS WORK\n");
} // setup