Browse Source

test real hardware

master
Olaf Rempel 12 years ago
parent
commit
60cccae208
4 changed files with 22 additions and 17 deletions
  1. +6
    -6
      include/board.h
  2. +10
    -4
      src/at91_adc.c
  3. +4
    -5
      src/at91_rttc_test.c
  4. +2
    -2
      src/at91_udp.c

+ 6
- 6
include/board.h View File

@@ -12,16 +12,16 @@
#define BAUD_TO_DIV(BAUD) (MCK / (16 * BAUD))

/* LED PIOs */
#define LED_ORANGE AT91C_PIO_PA17
#define LED_GREEN AT91C_PIO_PA18
#define LED_ORANGE AT91C_PIO_PA24
#define LED_GREEN AT91C_PIO_PA23

/* Taster PIOs */
#define TAST1 AT91C_PIO_PA19
#define TAST2 AT91C_PIO_PA20
#define TAST1 AT91C_PIO_PA0
#define TAST2 AT91C_PIO_PA1

/* USB PIOs */
#define UDP_VBUS_MON AT91C_PIO_PA24
#define UDP_PULLUP AT91C_PIO_PA25
#define UDP_VBUS_MON AT91C_PIO_PA8
#define UDP_PULLUP AT91C_PIO_PA16

/* ATMEL IDs */
#define USB_VENDOR_ID 0x03EB


+ 10
- 4
src/at91_adc.c View File

@@ -23,7 +23,7 @@
#include "board.h"
#include "at91_pitc.h"

static uint16_t adc_result[4];
static uint16_t adc_result[7];

static void at91_adc_isr(void)
{
@@ -40,12 +40,18 @@ static void at91_adc_isr(void)

static uint32_t adc_trigger(struct pitc_timer *timer)
{
uint32_t i;
for (i = 0; i < ARRAY_SIZE(adc_result); i++)
printf("0x%03x ", adc_result[i]);

printf("\n\r");

*AT91C_ADC_CR = AT91C_ADC_START;
return PITC_RESTART_TIMER;
}

static struct pitc_timer adc_timer = {
.interval = 100,
.interval = 10,
.func = &adc_trigger,
};

@@ -79,7 +85,7 @@ void at91_adc_test_init(void)
pdc->PDC_PTCR = AT91C_PDC_RXTEN;

/* enable 4 channels, PDC Interrupt */
adc->ADC_CHER = 0xF0;
adc->ADC_CHER = 0xF7;
adc->ADC_IER = AT91C_ADC_ENDRX;

/* low priority, level triggered, own vector */
@@ -88,5 +94,5 @@ void at91_adc_test_init(void)
aic->AIC_SVR[AT91C_ID_ADC] = (uint32_t)at91_adc_isr;
aic->AIC_IECR = (1<<AT91C_ID_ADC);

pitc_schedule_timer(&adc_timer);
// pitc_schedule_timer(&adc_timer);
}

+ 4
- 5
src/at91_rttc_test.c View File

@@ -6,22 +6,21 @@
static void rtt_isr(uint32_t status)
{
*AT91C_RTTC_RTAR = *AT91C_RTTC_RTVR +1;
/*
static uint32_t i;
*AT91C_PIOA_SODR = i;
i = i ^ LED_ORANGE;
*AT91C_PIOA_CODR = i;
*/
}

void at91_rttc_test_init(void)
{
/* calculate SLOWCK from MAINCK and measured MAINF */
uint32_t prescaler = MAINCK * 16 / (*AT91C_CKGR_MCFR & AT91C_CKGR_MAINF);
sysc_register_isr(AT91_SYSIRQ_RTT, &rtt_isr);

/*
/*
* AT91C_RTTC_RTTINCIEN doesn't work
* use AT91C_RTTC_ALMIEN and increment RTAR in isr
*/
@@ -29,6 +28,6 @@ void at91_rttc_test_init(void)
*AT91C_RTTC_RTMR = (AT91C_RTTC_RTPRES & prescaler) |
AT91C_RTTC_ALMIEN |
AT91C_RTTC_RTTRST;
printf("rttc running at %ld Hz\n\r", prescaler);
}

+ 2
- 2
src/at91_udp.c View File

@@ -543,10 +543,10 @@ static void udp_vbus_monitor(uint32_t status, uint32_t input)
{
if (input & UDP_VBUS_MON)
/* usb connected -> enable pullup */
*AT91C_PIOA_SODR = UDP_PULLUP;
*AT91C_PIOA_CODR = UDP_PULLUP;
else
/* usb got diconnected -> disable pullup */
*AT91C_PIOA_CODR = UDP_PULLUP;
*AT91C_PIOA_SODR = UDP_PULLUP;
}

PIO_PINCHANGE_ISR(UDP_VBUS_MON, udp_vbus_monitor);

Loading…
Cancel
Save