Exemple #1
0
// Now create any global variables such as motors, servos, sensors etc
// This routine is called once only and allows you to do set up the hardware
// Dont use any 'clock' functions here - use 'delay' functions instead
void appInitHardware(void){
	a2dSetPrescaler(ADC_PRESCALE_DIV128);

	cyrf6936_Initialise_hard();


	// Initialise SPI bus as master. (RF modules connected to hardware SPI)
    spiBusInit(&bus, TRUE);
	spiDeviceSelect(&cyrf_0, TRUE);
	spiDeviceSelect(&cyrf_0, FALSE);
	spiDeviceSelect(&cyrf_1, TRUE);
	spiDeviceSelect(&cyrf_1, FALSE);

	// set I/O pins for RF module(s).
	pin_make_input(D4, FALSE);		// set PACTL pin to input. (module on connector J1)
	pin_make_input(D5, FALSE);		// set PACTLn pin to input. (module on connector J1)
	pin_make_input(D6, FALSE);		// set PACTL pin to input. (module on connector J2)
	pin_make_input(D7, FALSE);		// set PACTLn pin to input. (module on connector J2)

#ifdef RF_MODULE_ARTAFLEX
	//
	pin_make_output(D4, FALSE);			// set RXPA pin to output. (module on connector J1)
	pin_make_output(D5, FALSE);			// set TXPA pin to output. (module on connector J1)
	pin_make_output(D6, FALSE);			// set RXPA pin to output. (module on connector J2)
	pin_make_output(D7, FALSE);			// set TXPA pin to output. (module on connector J2)
#endif

	pin_make_input(E7, TRUE);		// set UNIGEN RF module IRQ pin to input. (module on connector J1)
	pin_make_input(E6, TRUE);		// set UNIGEN RF module IRQ pin to input. (module on connector J2)
	pin_make_output(G3, FALSE);			// set UNIGEN RF module RST pin to output. (both modules)
	//pin_low(G3);					// don't reset yet.

	// set I/O pins for status LEDs
	pin_make_output(C0, TRUE);			// set LED pin for output
	pin_make_output(C1, TRUE);			// set LED pin for output
	pin_make_output(C2, FALSE);			// set LED pin for output
	//pin_high(C0);					// LED off
	//pin_high(C1);					// LED off
	//pin_low(C2);					// LED on


	// Set UART1 to 19200 baud
    uartInit(UART1, 38400);
    // Tell rprintf to output to UART1
    rprintfInit(&uart1SendByte);


    // Initialise the servo controller using Hardware PWM
    servoPWMInit(&bank1);


    // Initialise WatchDog Timer
    wdt_enable( WDTO_500MS );

}
Exemple #2
0
// ----------- Initialise my added devices ------
void initHardware(void){
	servoPWMInit(&_Servos1_);
	servoPWMInit(&_servos2_);
}