1 #include "platform_config.h"
10 #include "at91sam7s256.h"
15 sensor_t sensors[N_SENSORS] = {
27 for (i = 0; i < N_SENSORS; i++) {
30 nxt_avr_set_input_power(i, 0);
32 /* Ensure RS485 is inactive. Otherwise it can interfere with
33 * the operation of port 4.
35 *AT91C_PIOA_PER |= AT91C_PIO_PA5 | AT91C_PIO_PA6 | AT91C_PIO_PA7;
36 *AT91C_PIOA_PPUDR |= AT91C_PIO_PA5 | AT91C_PIO_PA6 | AT91C_PIO_PA7;
37 *AT91C_PIOA_OER |= AT91C_PIO_PA5 | AT91C_PIO_PA6 | AT91C_PIO_PA7;
38 *AT91C_PIOA_CODR |= AT91C_PIO_PA5 | AT91C_PIO_PA6 | AT91C_PIO_PA7;
48 sensor_t *pSensor = sensors;
50 for (i = 0; i < N_SENSORS; i++, pSensor++) {
51 pSensor->value = sensor_adc(i);
56 read_buttons(int dummy, short *output)
58 *output = (short) buttons_get();
63 check_for_data(char *valid, char **nextbyte)
71 /* Enable output on the pin */
73 int functions[] = { AT91C_PIO_PA23, AT91C_PIO_PA28,
74 AT91C_PIO_PA29, AT91C_PIO_PA30
77 *AT91C_PIOA_PER |= functions[sensor];
79 *AT91C_PIOA_OER |= functions[sensor];
83 *AT91C_PIOA_SODR |= functions[sensor];
88 unset_digi0(int sensor)
90 /* Enable output on the pin */
92 int functions[] = { AT91C_PIO_PA23, AT91C_PIO_PA28,
93 AT91C_PIO_PA29, AT91C_PIO_PA30
96 *AT91C_PIOA_PER |= functions[sensor];
98 *AT91C_PIOA_OER |= functions[sensor];
102 *AT91C_PIOA_CODR |= functions[sensor];
107 set_digi1(int sensor)
109 /* Enable output on the pin */
111 int functions[] = { AT91C_PIO_PA18, AT91C_PIO_PA19,
112 AT91C_PIO_PA20, AT91C_PIO_PA2
115 *AT91C_PIOA_PER |= functions[sensor];
117 *AT91C_PIOA_OER |= functions[sensor];
121 *AT91C_PIOA_SODR |= functions[sensor];
126 unset_digi1(int sensor)
128 /* Enable output on the pin */
130 int functions[] = { AT91C_PIO_PA18, AT91C_PIO_PA19,
131 AT91C_PIO_PA20, AT91C_PIO_PA2
134 *AT91C_PIOA_PER |= functions[sensor];
136 *AT91C_PIOA_OER |= functions[sensor];
140 *AT91C_PIOA_CODR |= functions[sensor];