Пример #1
0
int media_access_init(int drive)
{
	int ret;
	io_floppy_timeout = 0;

	ret = init_fdc(drive);
	if( ret != ERR_NO_ERROR )
		return ret;

	#ifdef DEBUG
	dbg_printf("init_fdc Done\n");
	#endif

	ret = media_init();
	if( ret == ERR_NO_ERROR )
	{
		#ifdef DEBUG
		dbg_printf("media_init done\n");
		#endif

		// Initialise File IO Library
		fl_init();

		#ifdef DEBUG
		dbg_printf("fl_init done\n");
		#endif

		/* Attach media access functions to library*/
		if (fl_attach_media(media_read, media_write) != FAT_INIT_OK)
		{
			return -ERR_MEDIA_ATTACH;
		}

		#ifdef DEBUG
		dbg_printf("fl_attach_media done\n");
		#endif

		return ERR_NO_ERROR;
	}

	return ret;
}
Пример #2
0
void application_main(void) 
{
    unsigned char toto[2][4]={{0x05,0x01,0x00,0xf0}, // 00000101, 00000001, 00000000, 11110000
                              {0x0A,0x02,0x00,0xf0}};// 00001010, 00000010, 00000000, 11110000

    // Reset the Timer0 value
    TMR0H = 0;
    TMR0L = 1;

    setalim();

    init_motors();
    setup_adconversion();
    init_servos();
    init_digitals_in();
    init_debug();
    init_fdc();

    set_fdc((unsigned char *)toto,2);

    SET_DEVICE_STATUS(REMOTE_WAKEUP_DIS);
    
    // Interruptions
    PIE2bits.USBIE = 0; // Interrupt USB off : on ne touche pas a la gestion de l'USB !!

    INTCONbits.PEIE = 1; // Interrupts peripheriques (usb, timer 1...)
    INTCONbits.GIE = 1; // Interrupts global

    while(usb_active_cfg > 2)
    {
        usb_sleep();
        dispatch_usb_event();
    }
    cutalim();
    PINDEBUG = 0;
    verif_fdc(0);
//    clear_device_remote_wakeup();
}