Browse Source

cleanup

master
Olaf Rempel 12 years ago
parent
commit
a8b04b8c9a
4 changed files with 17 additions and 11 deletions
  1. +1
    -1
      main.c
  2. +2
    -0
      src/at91_adc.c
  3. +2
    -1
      src/at91_tc1.c
  4. +12
    -9
      src/at91_udp.c

+ 1
- 1
main.c View File

@@ -63,7 +63,7 @@ static uint32_t stick_timer_cb(struct pitc_timer *timer)
global_state &= ~STICK_CALIBRATION;
}
} else {
} else if (count >= 4) {
if (rc.chan[2] < 0 && rc.chan[3] < 0)
global_state |= MOTORS_RUNNING;


+ 2
- 0
src/at91_adc.c View File

@@ -185,6 +185,8 @@ void at91_adc_init(void)
aic->AIC_SVR[AT91C_ID_ADC] = (uint32_t)at91_adc_isr;
aic->AIC_IECR = (1<<AT91C_ID_ADC);

adc_calibrate(ADC_CAL_GYRO);

/* load ACC calibration data */
twi_read_eeprom(EE_ACC_CAL_DATA, (uint8_t *)&(adc_offset[ADC_ACC_ROLL]), EE_ACC_CAL_DATA_SIZE);
printf("ACC offsets: %4d/%4d/%4d\n\r",


+ 2
- 1
src/at91_tc1.c View File

@@ -222,8 +222,9 @@ void rcontrol_calibrate(uint32_t mode)
void rcontrol_print_cal(void)
{
uint32_t i;
printf("stick-calibration:\n\r");
for (i = 0; i < ARRAY_SIZE(ch_data); i++) {
printf("%ld: %d(%+d) - %d(0) - %d(%+d)\n\r", i,
printf(" %ld: %d(%+d) - %d(0) - %d(%+d)\n\r", i,
ch_data[i].min, ch_data[i].min - ch_data[i].mid,
ch_data[i].mid,
ch_data[i].max, ch_data[i].max - ch_data[i].mid


+ 12
- 9
src/at91_udp.c View File

@@ -267,7 +267,7 @@ void ep_transfer_receive(uint32_t ep, char *data, uint32_t length,
/* stalls the endpoint */
static void ep_send_stall(uint32_t ep)
{
printf("stall\n\r");
printf("usb stall\n\r");
AT91C_UDP_CSR[ep] |= AT91C_UDP_FORCESTALL;
}

@@ -290,6 +290,12 @@ static void udp_configure_ep(const struct usb_endpoint_descriptor *desc)
*AT91C_UDP_IER = (1 << ep);
}

static void udp_print_config(void)
{
printf("usb: addr=%d cfg=%d if=%d\n\r",
current_address, current_config, current_interface);
}

/*
* set local address
* (USB_REQ_SET_ADDRESS callback)
@@ -298,6 +304,7 @@ static void udp_txcb_setaddress(void)
{
*AT91C_UDP_FADDR = (AT91C_UDP_FEN | current_address);
*AT91C_UDP_GLBSTATE = AT91C_UDP_FADDEN;
udp_print_config();
}

/*
@@ -312,17 +319,13 @@ static void udp_txcb_setconfig(void)

/* set UDP to "configured" */
*AT91C_UDP_GLBSTATE = AT91C_UDP_CONFG;
}

static void udp_txcb_setinterface(void)
{
printf("claim interface %d\n\r", current_interface);
udp_print_config();
}

static void ep_handle_ctrlrequest(struct usb_ctrlrequest *req)
{
printf("typ:0x%02x req:0x%02x val:0x%04x idx:0x%04x len:0x%04x\n\r",
req->bRequestType, req->bRequest, req->wValue, req->wIndex, req->wLength);
// printf("typ:0x%02x req:0x%02x val:0x%04x idx:0x%04x len:0x%04x\n\r",
// req->bRequestType, req->bRequest, req->wValue, req->wIndex, req->wLength);

switch (req->bRequestType & (USB_TYPE_MASK | USB_RECIP_MASK)) {
case (USB_TYPE_STANDARD | USB_RECIP_DEVICE): /* 0x00/0x80 */
@@ -385,7 +388,7 @@ static void ep_handle_ctrlrequest(struct usb_ctrlrequest *req)
switch (req->bRequest) {
case USB_REQ_SET_INTERFACE: /* 0x0b */
current_interface = req->wValue;
ep_transfer_send(0, NULL, 0, udp_txcb_setinterface);
ep_transfer_send(0, NULL, 0, udp_print_config);
break;

default:


Loading…
Cancel
Save