test real hardware
This commit is contained in:
parent
0302d9bdb0
commit
60cccae208
@ -12,16 +12,16 @@
|
|||||||
#define BAUD_TO_DIV(BAUD) (MCK / (16 * BAUD))
|
#define BAUD_TO_DIV(BAUD) (MCK / (16 * BAUD))
|
||||||
|
|
||||||
/* LED PIOs */
|
/* LED PIOs */
|
||||||
#define LED_ORANGE AT91C_PIO_PA17
|
#define LED_ORANGE AT91C_PIO_PA24
|
||||||
#define LED_GREEN AT91C_PIO_PA18
|
#define LED_GREEN AT91C_PIO_PA23
|
||||||
|
|
||||||
/* Taster PIOs */
|
/* Taster PIOs */
|
||||||
#define TAST1 AT91C_PIO_PA19
|
#define TAST1 AT91C_PIO_PA0
|
||||||
#define TAST2 AT91C_PIO_PA20
|
#define TAST2 AT91C_PIO_PA1
|
||||||
|
|
||||||
/* USB PIOs */
|
/* USB PIOs */
|
||||||
#define UDP_VBUS_MON AT91C_PIO_PA24
|
#define UDP_VBUS_MON AT91C_PIO_PA8
|
||||||
#define UDP_PULLUP AT91C_PIO_PA25
|
#define UDP_PULLUP AT91C_PIO_PA16
|
||||||
|
|
||||||
/* ATMEL IDs */
|
/* ATMEL IDs */
|
||||||
#define USB_VENDOR_ID 0x03EB
|
#define USB_VENDOR_ID 0x03EB
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "at91_pitc.h"
|
#include "at91_pitc.h"
|
||||||
|
|
||||||
static uint16_t adc_result[4];
|
static uint16_t adc_result[7];
|
||||||
|
|
||||||
static void at91_adc_isr(void)
|
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)
|
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;
|
*AT91C_ADC_CR = AT91C_ADC_START;
|
||||||
return PITC_RESTART_TIMER;
|
return PITC_RESTART_TIMER;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pitc_timer adc_timer = {
|
static struct pitc_timer adc_timer = {
|
||||||
.interval = 100,
|
.interval = 10,
|
||||||
.func = &adc_trigger,
|
.func = &adc_trigger,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,7 +85,7 @@ void at91_adc_test_init(void)
|
|||||||
pdc->PDC_PTCR = AT91C_PDC_RXTEN;
|
pdc->PDC_PTCR = AT91C_PDC_RXTEN;
|
||||||
|
|
||||||
/* enable 4 channels, PDC Interrupt */
|
/* enable 4 channels, PDC Interrupt */
|
||||||
adc->ADC_CHER = 0xF0;
|
adc->ADC_CHER = 0xF7;
|
||||||
adc->ADC_IER = AT91C_ADC_ENDRX;
|
adc->ADC_IER = AT91C_ADC_ENDRX;
|
||||||
|
|
||||||
/* low priority, level triggered, own vector */
|
/* 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_SVR[AT91C_ID_ADC] = (uint32_t)at91_adc_isr;
|
||||||
aic->AIC_IECR = (1<<AT91C_ID_ADC);
|
aic->AIC_IECR = (1<<AT91C_ID_ADC);
|
||||||
|
|
||||||
pitc_schedule_timer(&adc_timer);
|
// pitc_schedule_timer(&adc_timer);
|
||||||
}
|
}
|
||||||
|
@ -6,22 +6,21 @@
|
|||||||
static void rtt_isr(uint32_t status)
|
static void rtt_isr(uint32_t status)
|
||||||
{
|
{
|
||||||
*AT91C_RTTC_RTAR = *AT91C_RTTC_RTVR +1;
|
*AT91C_RTTC_RTAR = *AT91C_RTTC_RTVR +1;
|
||||||
/*
|
|
||||||
static uint32_t i;
|
static uint32_t i;
|
||||||
*AT91C_PIOA_SODR = i;
|
*AT91C_PIOA_SODR = i;
|
||||||
i = i ^ LED_ORANGE;
|
i = i ^ LED_ORANGE;
|
||||||
*AT91C_PIOA_CODR = i;
|
*AT91C_PIOA_CODR = i;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void at91_rttc_test_init(void)
|
void at91_rttc_test_init(void)
|
||||||
{
|
{
|
||||||
/* calculate SLOWCK from MAINCK and measured MAINF */
|
/* calculate SLOWCK from MAINCK and measured MAINF */
|
||||||
uint32_t prescaler = MAINCK * 16 / (*AT91C_CKGR_MCFR & AT91C_CKGR_MAINF);
|
uint32_t prescaler = MAINCK * 16 / (*AT91C_CKGR_MCFR & AT91C_CKGR_MAINF);
|
||||||
|
|
||||||
sysc_register_isr(AT91_SYSIRQ_RTT, &rtt_isr);
|
sysc_register_isr(AT91_SYSIRQ_RTT, &rtt_isr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AT91C_RTTC_RTTINCIEN doesn't work
|
* AT91C_RTTC_RTTINCIEN doesn't work
|
||||||
* use AT91C_RTTC_ALMIEN and increment RTAR in isr
|
* 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_RTMR = (AT91C_RTTC_RTPRES & prescaler) |
|
||||||
AT91C_RTTC_ALMIEN |
|
AT91C_RTTC_ALMIEN |
|
||||||
AT91C_RTTC_RTTRST;
|
AT91C_RTTC_RTTRST;
|
||||||
|
|
||||||
printf("rttc running at %ld Hz\n\r", prescaler);
|
printf("rttc running at %ld Hz\n\r", prescaler);
|
||||||
}
|
}
|
||||||
|
@ -543,10 +543,10 @@ static void udp_vbus_monitor(uint32_t status, uint32_t input)
|
|||||||
{
|
{
|
||||||
if (input & UDP_VBUS_MON)
|
if (input & UDP_VBUS_MON)
|
||||||
/* usb connected -> enable pullup */
|
/* usb connected -> enable pullup */
|
||||||
*AT91C_PIOA_SODR = UDP_PULLUP;
|
*AT91C_PIOA_CODR = UDP_PULLUP;
|
||||||
else
|
else
|
||||||
/* usb got diconnected -> disable pullup */
|
/* usb got diconnected -> disable pullup */
|
||||||
*AT91C_PIOA_CODR = UDP_PULLUP;
|
*AT91C_PIOA_SODR = UDP_PULLUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
PIO_PINCHANGE_ISR(UDP_VBUS_MON, udp_vbus_monitor);
|
PIO_PINCHANGE_ISR(UDP_VBUS_MON, udp_vbus_monitor);
|
||||||
|
Loading…
Reference in New Issue
Block a user