Beispiel #1
0
void UserInit(void)
{
    mInitAllLEDs();
    mInitAllSwitches();

	blinkStatusValid = TRUE;	//Blink the normal USB state on the LEDs.
	// Enable Channel 0 and Channel 1 for ADC
	
	// Disable A/D first.
	ADCON0bits.ADON = 0;
	// Select channel as per user request. But default to AD0
	ADCON0 &= (0xF0);
	ADCON1bits.VCFG1 = 0; // Vss for Vref-
	ADCON1bits.VCFG0 = 0; // Vdd for Vref+
	// AN0 and AN1 are analog pins
	ADCON1bits.PCFG0 = 1;
	ADCON1bits.PCFG1 = 0;
	ADCON1bits.PCFG2 = 1;
	ADCON1bits.PCFG3 = 1;
	// A/D is little endian
	ADCON2bits.ADFM = 1;
	// Set aquisition time of 2 cycles.
	ADCON2bits.ACQT0 = 1;
	ADCON2bits.ACQT1 = 0;
	ADCON2bits.ACQT2 = 0;
	// Set conversion time of 64 clock cycles
	ADCON2bits.ADCS0 = 0;
	ADCON2bits.ADCS1 = 1;
	ADCON2bits.ADCS2 = 1;
	
	// Make RA0 and RA1 as input.
	TRISAbits.TRISA0 = 1;
	TRISAbits.TRISA1 = 1;
	
}//end UserInit
Beispiel #2
0
void UserInit(void) {
    //Initialize all of the LED pins
    mInitAllLEDs();

    //Initialize the pushbuttons
    mInitAllSwitches();
}
Beispiel #3
0
/******************************************************************************
 * Function:        void UserInit(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        This routine should take care of all of the demo code
 *                  initialization that is required.
 *
 * Note:            
 *
 *****************************************************************************/
void UserInit(void)
{
    //Initialize all of the LED pins
    mInitAllLEDs();
    
    //Initialize all of the push buttons
    mInitAllSwitches();
    old_sw2 = sw2;
    old_sw3 = sw3;
    
    PORTBbits.RB4 = 0;	//Clear RB4 to a known value
	ANSELHbits.ANS10 = 1;	//make RB4 an analog I/O	
	TRISBbits.TRISB4 = 1;	//set RB4 as an input


//Configure ADC as follows
//	Use AN10 or RB4 as the variable input
//	clear GODONE and turn on ADC module
    //ADCON0=0x29;
    //ADCON1 = 0X00;	//use VDD and VSS as references
    
    //ADCON2=0x3F;  // left justified, 20Tad, Fosc/4

    //initialize the variable holding the handle for the last
    // transmission

    lastTransmission = 0;

}//end UserInit
Beispiel #4
0
void UserInit(void)
{
	mInitAllLEDs();
	mInitAllSwitches();
	InitAdc();
	old_sw2 = sw2;
	Pump1tris = 0;
	Pump2tris = 0;
	
	TRISVPP = 0; //output
	TRISVPP_RST=0; //output
	TRISPGD=0;    
	TRISPGC=0;    
	TRISVDD=0;
	TRISVPP_RUN=0;
	VPP_RUN=0;	//run = off
	PGD_LOW=1;
	TRISPGD_LOW=1; //LV devices disabled, high impedance / input
	PGC_LOW=1;
	TRISPGC_LOW=1; //LV devices disabled, high impedance / input
	VPP = 1; //VPP is low (inverted)
	VPP_RST=0; //No hard reset (inverted
	PGD=0;		
	PGC=0;
	INTCON2bits.RBPU=1; //disable Portb pullup resistors
	timer1Init();
	timer0Init();
}//end UserInit
Beispiel #5
0
/***************************************************
 * Function:        InitializeDevice(void)
 *
 * OverView:		Initialize Device Port, LED, Switches, ADC, PWM, TIMER, ETC..
 *
 * Note:			None
 ***************************************************/
void InitializeDevice(void)
{
	//Initialize all of the LED pins
	mInitAllLEDs();	
	LED_INIT();

    //Initialize all of the push buttons
    mInitAllSwitches();

	//initialize adc for ntc sensor
	InitADC();

	//initialize lid heater
	InitHeater();

	//initialize fan
	Init_ChamberFan();
	Init_SystemFan();

	//initialize pwm 	
	Stop_PWM_MODE();

	//initialize fan & heater control with timer0
	TIMR0_init();

	//pcr task tick
	TIMR1_init();
}
Beispiel #6
0
void UserInit(void)
{
	mInitConversion();	// Initialise all the conversion values required for ISR maths
    mInitAllSwitches();	// Initislise the switches in accordance to the hardware profile
	mInitEEPROM();		// Read in any saved values from EEPROM
    mInitAllLEDs();		// Initialise the LEDs in acordance to the hardware profile	
	mLCD_power_init();	// initialise the LCD backlight
 	mInitDAQ();			// Initialise the Data Acquisition parameters (AN inputs etc)
	if (debug==FALSE)
	{
		mInitLCD();			// Must comment this out when testing as LCD will never initialise...
	}
	mInitSPI();			// Initialise the SPI interface for talking to the LED driver (must be after the LCD)
    mInitInterrupts();	// Initialise the interrupts/timers etc
	if(backlight_flag==TRUE)
	{
		LCD_ramp_up=TRUE;		// turn on the LCD back light
	}	
}//end UserInit
Beispiel #7
0
void UserInit(void)
{
    mInitAllLEDs();
    mInitAllSwitches();
    old_sw2 = sw2;
    old_sw3 = sw3;
    
    InitTempSensor();
    mInitPOT();
  
    ResetTempLog();
    temp_mode = TEMP_REAL_TIME;
    
    #if defined(__18CXX)
    /* Init Timer0 for data logging interval (every 1 second) */
    T0CON = 0b10010111;
    /* Timer0 is already enabled by default */
    #elif defined(__C30__) || defined __XC16__
    #endif
}//end UserInit
Beispiel #8
0
/******************************************************************************
 * Function:        void UserInit(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        This routine should take care of all of the demo code
 *                  initialization that is required.
 *
 * Note:
 *
 *****************************************************************************/
void UserInit(void)
{
    //Initialize all of the debouncing variables
    buttonCount = 0;
    buttonPressed = FALSE;
    stringPrinted = TRUE;

    //Initialize all of the LED pins
    mInitAllLEDs();

    //Initialize the pushbuttons
    mInitAllSwitches();

    // Initialize UART
    InitializeUSART();

    // Disable all unused peripherals
    DisablePeripherals();

    // Sleep until UART interrupt

}//end UserInit
Beispiel #9
0
/******************************************************************************
 * Function:        void UserInit(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        This routine should take care of all of the demo code
 *                  initialization that is required.
 *
 * Note:
 *
 *****************************************************************************/
void UserInit(void)
{
    //Initialize all of the LED pins
    mInitAllLEDs();

    //Initialize all of the push buttons
    mInitAllSwitches();
    old_sw2 = sw2;
    old_sw3 = sw3;

    //Initialize all of the mouse data to 0,0,0 (no movement)
    buffer[0]=buffer[1]=buffer[2]=0;

    //enable emulation mode.  This means that the mouse data
    //will be send to the PC causing the mouse to move.  If this is
    //set to FALSE then the demo board will send 0,0,0 resulting
    //in no mouse movement
    emulate_mode = TRUE;

    //initialize the variable holding the handle for the last
    // transmission
    lastTransmission = 0;
}//end UserInit
Beispiel #10
0
void InitializeSystem(void) {
  ADCON1 |= 0x0F;  // Default all pins to digital
  INTCON2 = 0;
  mInitAllLEDs();
  mInitAllSwitches();

  g_blink_status_valid = TRUE;
  g_usb_handle_in = 0;
  g_usb_handle_out = 0;

  // Reset TX queue and read config from the EEPROM.
  memset(g_tx_queue, 0, sizeof(g_tx_queue));
  EEADR = 0;
  EECON1bits.EEPGD = 0;
  EECON1bits.CFGS = 0;
  EECON1bits.RD = 1;
  g_lgtm_strings_idx = EEDATA;
  if (g_lgtm_strings_idx >= NUM_LGTM_STRINGS)
    g_lgtm_strings_idx = 0;
  g_lgtm_ascii_ptr = LGTM_STRINGS[g_lgtm_strings_idx];

  USBDeviceInit();  // usb_device.c.  Initializes USB module SFRs and firmware
                    // variables to known states.
}
Beispiel #11
0
void BLIO_InitializeIO ( void )
{
    mInitAllSwitches();
    mInitAllLEDs();
}
Beispiel #12
0
Datei: user.c Projekt: klvt/fiwt
void InitApp(void) {
    /* Send Low Level Voltage to all ports */
    LATA = 0x0000;
    LATB = 0x0000;
    LATC = 0x0000;
    LATD = 0x0000;
    LATE = 0x0000;
    LATF = 0x0000;
    LATG = 0x0000;
#if defined(__dsPIC33EP512MU814__)
    LATH = 0x0000;
    LATJ = 0x0000;
    LATK = 0x0000;
#endif

    /* Disable all analog inputs */
    ANSELA = 0x0000;
    ANSELB = 0x0000;
    ANSELC = 0x0000;
    ANSELD = 0x0000;
    ANSELE = 0x0000;
    ANSELG = 0x0000;

    /* Configure all digital ports as outputs */
    TRISA = 0x0000;
    TRISB = 0x0000;
    TRISC = 0x0000;
    TRISD = 0x0000;
    TRISE = 0x0000;
    TRISF = 0x0000;
    TRISG = 0x0000;
#if defined(__dsPIC33EP512MU814__)
    TRISH = 0x0000;
    TRISJ = 0x0000;
    TRISK = 0x0000;
#endif

#if STARTKITBOARD
    mInitAllLEDs();
    mInitAllSwitches();
#endif
    
    /* Configure Nested Interrupts */
    INTCON1bits.NSTDIS = 0b0; // Interrupt nesting enabled

    initClock();

#if USE_UART1
    serial_assign(&Serial1, 1u);
    Serial1.init();
    Serial1.open();
    XBeeInit(&Xbee1, XBEE1_ATAP, &Serial1);
#endif /*USE_UART1*/
#if USE_UART2
    serial_assign(&Serial2, 2u);
    Serial2.init();
    Serial2.open();
    XBeeInit(&Xbee2, XBEE2_ATAP, &Serial2);
#endif /*USE_UART2*/
#if USE_UART3
    serial_assign(&Serial3, 3u);
    Serial3.init();
    Serial3.open();
    XBeeInit(&Xbee3, XBEE3_ATAP, &Serial3);
#endif /*USE_UART3*/
#if USE_UART4
    serial_assign(&Serial4, 4u);
    Serial4.init();
    Serial4.open();
    XBeeInit(&Xbee4, XBEE4_ATAP, &Serial4);
#endif /*USE_UART4*/

#if USE_ADC1
    ADC1Init();
    ADC1Start();
#endif

#if USE_ENC
    EncInit();
#endif

#if USE_PWM
    PWMxInit();
    PWMxStart();
#endif

#if USE_PWM && USE_ADC1
    ServoInit();
    asm ("repeat #640;");
    Nop();
    ServoStart();
#endif /* USE_PWM && USE_ADC1 */

#if USE_IMU
    IMUInit();
    IMUStart();
#endif

#if USE_SPIS
    SPISInit();
    SPISStart();
#endif
}