コード例 #1
0
ファイル: F2837xD_Adc.c プロジェクト: drjwhut/cprjwlnet
void InitADC(void)
{
	EALLOW;

	//write configurations
	AdcaRegs.ADCCTL2.bit.PRESCALE = 0X2; //set ADCCLK divider to /4
	AdcbRegs.ADCCTL2.bit.PRESCALE = 0X2; //set ADCCLK divider to /4
	AdccRegs.ADCCTL2.bit.PRESCALE = 0X2; //set ADCCLK divider to /4
	AdcdRegs.ADCCTL2.bit.PRESCALE = 0X2; //set ADCCLK divider to /4

    AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
    AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
    AdcSetMode(ADC_ADCC, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
    AdcSetMode(ADC_ADCD, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);

	//Set pulse positions to late
	AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
	AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1;
	AdccRegs.ADCCTL1.bit.INTPULSEPOS = 1;
	AdcdRegs.ADCCTL1.bit.INTPULSEPOS = 1;

	//power up the ADC
	AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
	AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1;
	AdccRegs.ADCCTL1.bit.ADCPWDNZ = 1;
	AdcdRegs.ADCCTL1.bit.ADCPWDNZ = 1;

	//delay for 1ms to allow ADC time to power up
	DELAY_US(1000);

	EDIS;

	SetupADC();
}
コード例 #2
0
int main ( void )
{
    fun_queue = queueInit(FUN_Q_LEN);
    rx_pay_queue = pqInit(12); //replace 12 with a #define const later
    test_function tf;

    /* Initialization */
    SetupClock();
    SwitchClocks();
    SetupPorts();

    SetupInterrupts();
    SetupI2C();
    SetupADC();
    SetupTimer1();
    SetupPWM();
    SetupTimer2();
    gyroSetup();
    xlSetup();
    dfmemSetup();

    WordVal pan_id    = {RADIO_PAN_ID};
    WordVal src_addr  = {RADIO_SRC_ADDR};
    WordVal dest_addr = {RADIO_DEST_ADDR};

    radioInit(src_addr, pan_id, RADIO_RXPQ_MAX_SIZE, RADIO_TXPQ_MAX_SIZE);
    radioSetDestAddr(dest_addr);
    radioSetChannel(RADIO_MY_CHAN);

    char j;
    for(j=0; j<3; j++){
        LED_2 = ON;
        delay_ms(500);
        LED_2 = OFF;
        delay_ms(500);
    }

    LED_2 = ON;

    EnableIntT2;
    while(1){
        while(!queueIsEmpty(fun_queue))
        {
            rx_payload = pqPop(rx_pay_queue);
            tf = (test_function)queuePop(fun_queue);
            (*tf)(payGetType(rx_payload), payGetStatus(rx_payload), payGetDataLength(rx_payload), payGetData(rx_payload));
            payDelete(rx_payload);
        }
    }
    return 0;
}
コード例 #3
0
ファイル: wunder.c プロジェクト: KamalChaya/KamalC_code
void initialize( void )
{
	CPU_PRESCALE(0);
	
	USART_Init(BAUD_RATE);
	USART_Transmit('\f');	// Send form feed to clear the terminal.
	USART_SendString("WunderBoard initializing...\r\n");
	
	USART_SendString("\tSetting ADC prescaler and disabling free running mode...\r\n");
	SetupADC(ADC_PRESCALER_32, FALSE);
	
	USART_SendString("\tEnabling ADC...\r\n");
	ADCEnable();
	
	USART_SendString("\tSetting ADC reference to Vcc...\r\n");
	ADCSetReference(ADC_REF_VCC);
	
	// Configure IO //
	USART_SendString("\tConfiguring IO...\r\n");
	//DDRx corresponds to PORTx/PINx, dependng on direction of data flow -- PORT for output, PIN for input
	DDRA = 0x00;	// Buttons and switches
	DDRB = 0xE7;	// Red enable, green enable and audio out
	DDRC = 0xff;	// Discrete LEDs
	DDRE = 0x47;	// LED Column
	DDRF = 0x00;	// Accelerometer
	
	// Disable pullups and set outputs low //
	PORTA = 0x00;
	PORTB = 0x01;
	PORTC = 0x81;
	PORTE = 0x00;
	PORTF = 0x00;
	
	//Set OC1A to toggle
	TCCR1A = 0b01000000;
	// Clk/64 and CTC mode
	TCCR1B = 0b00001011;

	OCR1A = 24;

	USART_SendString("\tSetting SPI\r\n");
	
	//Set the SPI bus appropriately to use the LED array
	SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);

}
コード例 #4
0
ファイル: main.c プロジェクト: camrose/unsteady_optical_flow
int main (void)
{
    unsigned int i;

    /* Initialization */
    SetupClock();
    SetupPorts();
    batSetup();
    cmdSetup();
    mcSetup();
    SetupADC();
    SwitchClocks();
    sclockSetup();

    radioInit(TXPQ_MAX_SIZE, RXPQ_MAX_SIZE);
    radioSetChannel(MY_CHAN);
    radioSetSrcPanID(PAN_ID);
    radioSetSrcAddr(SRC_ADDR);

    dfmemSetup();
    camSetup();
    cambuffSetup();
    gyroSetup();

    cmdResetSettings();

    for (i = 0; i < 6; i++)
    {
        LED_GREEN  = ~LED_GREEN;  delay_ms(50);
        LED_RED    = ~LED_RED;    delay_ms(50);
        LED_ORANGE = ~LED_ORANGE; delay_ms(50);
    }
    LED_GREEN = 0; LED_RED = 0; LED_ORANGE = 0;

    /* Program */
    while (1)
    {
        cmdHandleRadioRxBuffer();
        radioProcess();
    }
}