void main()
{
    systemInit();
    applicationInit();

    while (1)
    {
        applicationTask();
    }
}
Exemple #2
0
// Initialise the PIC
void initialisePic(void)
{
    // PIC port set up --------------------------------------------------------

	// Default all pins to digital
    ANSEL = 0x00;

	// Configure ports as inputs (1) or outputs(0)
/*	TRISA = 0b11111111;
	TRISB = 0b11111111;
	TRISC = 0b11111111;
#if defined(__18F4550)
	TRISD = 0b00000000;
	TRISE = 0b00000000;
#endif

	// Clear all ports
	PORTA = 0b00000000;
	PORTB = 0b00000000;
	PORTC = 0b00000000;
#if defined(__18F4550)
	PORTD = 0b00000000;
	PORTE = 0b00000000;
#endif*/

	PORTC = 0x00;
	LATC = 0x00;

	TRISC = 0x04;

	// If you have a VBUS sense pin (for self-powered devices when you
	// want to detect if the USB host is connected) you have to specify
	// your input pin in HardwareProfile.h
    #if defined(USE_USB_BUS_SENSE_IO)
    	tris_usb_bus_sense = INPUT_PIN;
    #endif
    
    // In the case of a device which can be both self-powered and bus-powered
    // the device must respond correctly to a GetStatus (device) request and
    // tell the host how it is currently powered.
    //
    // To do this you must device a pin which is high when self powered and low
    // when bus powered and define this in HardwareProfile.h
    #if defined(USE_SELF_POWER_SENSE_IO)
    	tris_self_power = INPUT_PIN;
    #endif

    // Application specific initialisation
    applicationInit();
    
    // Initialise the USB device
    USBDeviceInit();
}
Exemple #3
0
// Initialise the PIC
static void initialisePic(void)
{
    // PIC port set up --------------------------------------------------------

	// Default all pins to digital
    ADCON1 = 0x0F;

    // Configure ports as inputs (1) or outputs(0)
    TRISA = 0b00000000;
    TRISB = 0b00000000;
    TRISC = 0b00000000;
    TRISD = 0b00000000;
    TRISE = 0b00000000;

    // Clear all ports
    PORTA = 0b00000000;
    PORTB = 0b00000000;
    PORTC = 0b00000000;
    PORTD = 0b00000000;
    PORTE = 0b00000000;

    // initialise the atmega IC
    atmegaFeederRunningTRIS = 1;
    atmegaResetPin = 1;
    
    
    // initialise i2c communication
    OpenI2C( MASTER, SLEW_OFF);
    SSPADD = 0x70;
    
    // Application specific initialisation
    applicationInit();
    
    // Initialise the USB device
    USBDeviceInit();

    // Initialise the output pins
    setVac1off;
    setVac2off;
    setVibrationoff;
    OpenTimer2( TIMER_INT_OFF & T2_PS_1_1);

    // load pwm values from eeprom
    led1_duty_cycle = Read_b_eep(baseLED_EEPROM_address);
    led2_duty_cycle = Read_b_eep(headLED_EEPROM_address);

    // initialise the stepper driver and start timer 0 at 1 microsecond intervals
    
    
}