Fixed invalid USB controller PLL prescaler values for the ATMEGAxxU2 controllers
Fixed lack of support for the ATMEGA32U2 in the DFU and CDC class bootloaders Changed incomplete Webserver project over to using the uIP timer library.
This commit is contained in:
parent
f0d6d4ef13
commit
77dda302ac
10 changed files with 81 additions and 60 deletions
|
@ -12,7 +12,7 @@
|
|||
volatile clock_time_t clock_datetime = 0;
|
||||
|
||||
//Overflow interrupt
|
||||
ISR(TIMER0_OVF_vect)
|
||||
ISR(TIMER1_COMPA_vect)
|
||||
{
|
||||
clock_datetime += 1;
|
||||
}
|
||||
|
@ -20,14 +20,10 @@ ISR(TIMER0_OVF_vect)
|
|||
//Initialise the clock
|
||||
void clock_init()
|
||||
{
|
||||
//Activate overflow interrupt for timer0
|
||||
TIMSK0 |= (1<<TOIE0);
|
||||
|
||||
//Use prescaler 1024
|
||||
TCCR0B |= ((1<<CS12)|(1<<CS10));
|
||||
|
||||
//Activate interrupts
|
||||
sei();
|
||||
OCR1A = ((F_CPU / 1024) / 100);
|
||||
TCCR1A = (1 << WGM12);
|
||||
TCCR1B = ((1 << CS12) | (1 << CS10));
|
||||
TIMSK1 = (1 << OCIE1A);
|
||||
}
|
||||
|
||||
//Return time
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
typedef uint16_t clock_time_t;
|
||||
#define CLOCK_CONF_SECOND (F_CPU / 1024 / 255) //Freqency divided prescaler and counter register size
|
||||
#define CLOCK_CONF_SECOND 100
|
||||
void clock_init(void);
|
||||
clock_time_t clock_time(void);
|
||||
|
||||
|
|
|
@ -57,13 +57,13 @@ USB_ClassInfo_RNDIS_Host_t Ethernet_RNDIS_Interface =
|
|||
},
|
||||
};
|
||||
|
||||
volatile uint8_t uIPManagementTimeout;
|
||||
struct timer ConnectionTimer, ARPTimer;
|
||||
uint16_t MillisecondTickCount;
|
||||
|
||||
/** ISR for the management of the connection management timeout counter */
|
||||
ISR(TIMER0_COMPA_vect, ISR_BLOCK)
|
||||
{
|
||||
if (uIPManagementTimeout)
|
||||
uIPManagementTimeout--;
|
||||
MillisecondTickCount++;
|
||||
}
|
||||
|
||||
void TCPCallback(void)
|
||||
|
@ -186,9 +186,8 @@ void ProcessIncommingPacket(void)
|
|||
printf("0x%02X ", uip_buf[i]);
|
||||
printf("\r\n\r\n");
|
||||
|
||||
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
|
||||
|
||||
if (BUF->type == HTONS(UIP_ETHTYPE_IP))
|
||||
struct uip_eth_hdr* EthernetHeader = (struct uip_eth_hdr*)&uip_buf[0];
|
||||
if (EthernetHeader->type == HTONS(UIP_ETHTYPE_IP))
|
||||
{
|
||||
/* Filter packet by MAC destination */
|
||||
uip_arp_ipin();
|
||||
|
@ -200,7 +199,7 @@ void ProcessIncommingPacket(void)
|
|||
if (uip_len > 0)
|
||||
uip_arp_out();
|
||||
}
|
||||
else if (BUF->type == HTONS(UIP_ETHTYPE_ARP))
|
||||
else if (EthernetHeader->type == HTONS(UIP_ETHTYPE_ARP))
|
||||
{
|
||||
/* Process ARP packet */
|
||||
uip_arp_arpin();
|
||||
|
@ -221,8 +220,10 @@ void ProcessIncommingPacket(void)
|
|||
|
||||
void ManageConnections(void)
|
||||
{
|
||||
if (!(uIPManagementTimeout))
|
||||
if (timer_expired(&ConnectionTimer))
|
||||
{
|
||||
timer_reset(&ConnectionTimer);
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
for (uint8_t i = 0; i < UIP_CONNS; i++)
|
||||
|
@ -235,12 +236,14 @@ void ManageConnections(void)
|
|||
RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, &uip_buf, uip_len);
|
||||
}
|
||||
|
||||
uip_arp_timer();
|
||||
|
||||
uIPManagementTimeout = 250;
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
}
|
||||
|
||||
if (timer_expired(&ARPTimer))
|
||||
{
|
||||
timer_reset(&ARPTimer);
|
||||
uip_arp_timer();
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
|
@ -258,22 +261,21 @@ void SetupHardware(void)
|
|||
LEDs_Init();
|
||||
USB_Init();
|
||||
|
||||
/* Millisecond timer initialization for managing the command timeout counter */
|
||||
OCR0A = ((F_CPU / 64) / 1000);
|
||||
TCCR0A = (1 << WGM01);
|
||||
TCCR0B = ((1 << CS01) | (1 << CS00));
|
||||
|
||||
/* uIP Timing Initialization */
|
||||
clock_init();
|
||||
timer_set(&ConnectionTimer, CLOCK_SECOND / 2);
|
||||
timer_set(&ARPTimer, CLOCK_SECOND * 10);
|
||||
|
||||
/* uIP Stack Initialization */
|
||||
uip_init();
|
||||
|
||||
uip_ipaddr_t IPAddress, Netmask, GatewayIPAddress;
|
||||
uip_ipaddr(&IPAddress, 192, 168, 1, 10);
|
||||
uip_ipaddr(&Netmask, 0xFF, 0xFF, 0xFF, 0x00);
|
||||
uip_ipaddr(&IPAddress, 192, 168, 1, 10);
|
||||
uip_ipaddr(&Netmask, 255, 255, 255, 0);
|
||||
uip_ipaddr(&GatewayIPAddress, 192, 168, 1, 1);
|
||||
uip_sethostaddr(&IPAddress);
|
||||
uip_setnetmask(&Netmask);
|
||||
uip_setdraddr(&GatewayIPAddress);
|
||||
|
||||
|
||||
/* HTTP Webserver Initialization */
|
||||
uip_listen(HTONS(80));
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
|
||||
#include <uip.h>
|
||||
#include <uip_arp.h>
|
||||
#include <timer.h>
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
|
|
|
@ -142,6 +142,7 @@ SRC = $(TARGET).c \
|
|||
Lib/uip/psock.c \
|
||||
Lib/uip/timer.c \
|
||||
Lib/uip/uip-neighbor.c \
|
||||
Lib/uip/conf/clock-arch.c \
|
||||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue