1
0

Add support for ATmega32a

This commit is contained in:
Kai Ryu 2014-04-09 16:09:55 +09:00
parent 963adae486
commit 9635039ab8
9 changed files with 56 additions and 26 deletions

View File

@ -18,6 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef BOOTLOADER_H
#define BOOTLOADER_H
#ifndef MCUSR
#define MCUSR MCUCSR
#endif
/* give code for your bootloader to come up if needed */
void bootloader_jump(void);

View File

@ -87,6 +87,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#else
# define REPORT_SIZE 8
# define REPORT_KEYS 6
# define REPORT_BITS 7
#endif

View File

@ -28,18 +28,18 @@ volatile uint32_t timer_count = 0;
void timer_init(void)
{
// Timer0 CTC mode
TCCR0A = 0x02;
TCCR0A |= (1<<WGM01 | 0<<WGM00);
#if TIMER_PRESCALER == 1
TCCR0B = 0x01;
TCCR0B |= (0<<CS02 | 0<<CS01 | 1<<CS00);
#elif TIMER_PRESCALER == 8
TCCR0B = 0x02;
TCCR0B |= (0<<CS02 | 1<<CS01 | 0<<CS00);
#elif TIMER_PRESCALER == 64
TCCR0B = 0x03;
TCCR0B |= (0<<CS02 | 1<<CS01 | 1<<CS00);
#elif TIMER_PRESCALER == 256
TCCR0B = 0x04;
TCCR0B |= (1<<CS02 | 0<<CS01 | 0<<CS00);
#elif TIMER_PRESCALER == 1024
TCCR0B = 0x05;
TCCR0B |= (1<<CS02 | 0<<CS01 | 1<<CS00);
#else
# error "Timer prescaler value is NOT vaild."
#endif

View File

@ -45,6 +45,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define TIMER_DIFF_32(a, b) TIMER_DIFF(a, b, UINT32_MAX)
#define TIMER_DIFF_RAW(a, b) TIMER_DIFF_8(a, b)
#ifndef TCCR0A
#define TCCR0A TCCR0
#endif
#ifndef TCCR0B
#define TCCR0B TCCR0
#endif
#ifndef TIMSK0
#define TIMSK0 TIMSK
#endif
#ifndef OCIE0A
#define OCIE0A OCIE0
#endif
#ifndef OCR0A
#define OCR0A OCR0
#endif
#ifndef TIMER0_COMPA_vect
#define TIMER0_COMPA_vect TIMER0_COMP_vect
#endif
#ifdef __cplusplus
extern "C" {

View File

@ -8,9 +8,10 @@ SRC += $(VUSB_DIR)/main.c \
$(VUSB_DIR)/usbdrv/usbdrvasm.S \
$(VUSB_DIR)/usbdrv/oddebug.c
COMMON_DIR = common
ifdef NO_UART
SRC += $(COMMON_DIR)/sendchar_null.c
OPT_DEFS += -DNO_UART
else
SRC += $(COMMON_DIR)/sendchar_uart.c \
$(COMMON_DIR)/uart.c

View File

@ -48,9 +48,14 @@ int main(void)
uint16_t last_timer = timer_read();
#endif
#ifdef CLKPR
CLKPR = 0x80, CLKPR = 0;
#endif
#ifndef NO_UART
#ifndef PS2_USE_USART
uart_init(UART_BAUD_RATE);
#endif
#endif
keyboard_init();

View File

@ -45,7 +45,7 @@ uchar usbCurrentDataToken;/* when we check data toggling to ignore duplica
#endif
/* USB status registers / not shared with asm code */
uchar *usbMsgPtr; /* data to transmit next -- ROM or RAM address */
const uchar *usbMsgPtr; /* data to transmit next -- ROM or RAM address */
static usbMsgLen_t usbMsgLen = USB_NO_MSG; /* remaining number of bytes */
static uchar usbMsgFlags; /* flag values see below */
@ -67,7 +67,7 @@ optimizing hints:
#if USB_CFG_DESCR_PROPS_STRING_0 == 0
#undef USB_CFG_DESCR_PROPS_STRING_0
#define USB_CFG_DESCR_PROPS_STRING_0 sizeof(usbDescriptorString0)
PROGMEM char usbDescriptorString0[] = { /* language descriptor */
PROGMEM const char usbDescriptorString0[] = { /* language descriptor */
4, /* sizeof(usbDescriptorString0): length of descriptor in bytes */
3, /* descriptor type */
0x09, 0x04, /* language index (0x0409 = US-English) */
@ -77,7 +77,7 @@ PROGMEM char usbDescriptorString0[] = { /* language descriptor */
#if USB_CFG_DESCR_PROPS_STRING_VENDOR == 0 && USB_CFG_VENDOR_NAME_LEN
#undef USB_CFG_DESCR_PROPS_STRING_VENDOR
#define USB_CFG_DESCR_PROPS_STRING_VENDOR sizeof(usbDescriptorStringVendor)
PROGMEM int usbDescriptorStringVendor[] = {
PROGMEM const int usbDescriptorStringVendor[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_VENDOR_NAME_LEN),
USB_CFG_VENDOR_NAME
};
@ -86,7 +86,7 @@ PROGMEM int usbDescriptorStringVendor[] = {
#if USB_CFG_DESCR_PROPS_STRING_PRODUCT == 0 && USB_CFG_DEVICE_NAME_LEN
#undef USB_CFG_DESCR_PROPS_STRING_PRODUCT
#define USB_CFG_DESCR_PROPS_STRING_PRODUCT sizeof(usbDescriptorStringDevice)
PROGMEM int usbDescriptorStringDevice[] = {
PROGMEM const int usbDescriptorStringDevice[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_DEVICE_NAME_LEN),
USB_CFG_DEVICE_NAME
};
@ -95,7 +95,7 @@ PROGMEM int usbDescriptorStringDevice[] = {
#if USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER == 0 && USB_CFG_SERIAL_NUMBER_LEN
#undef USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER sizeof(usbDescriptorStringSerialNumber)
PROGMEM int usbDescriptorStringSerialNumber[] = {
PROGMEM const int usbDescriptorStringSerialNumber[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_SERIAL_NUMBER_LEN),
USB_CFG_SERIAL_NUMBER
};
@ -108,7 +108,7 @@ PROGMEM int usbDescriptorStringSerialNumber[] = {
#if USB_CFG_DESCR_PROPS_DEVICE == 0
#undef USB_CFG_DESCR_PROPS_DEVICE
#define USB_CFG_DESCR_PROPS_DEVICE sizeof(usbDescriptorDevice)
PROGMEM char usbDescriptorDevice[] = { /* USB device descriptor */
PROGMEM const char usbDescriptorDevice[] = { /* USB device descriptor */
18, /* sizeof(usbDescriptorDevice): length of descriptor in bytes */
USBDESCR_DEVICE, /* descriptor type */
0x10, 0x01, /* USB version supported */
@ -139,7 +139,7 @@ PROGMEM char usbDescriptorDevice[] = { /* USB device descriptor */
#if USB_CFG_DESCR_PROPS_CONFIGURATION == 0
#undef USB_CFG_DESCR_PROPS_CONFIGURATION
#define USB_CFG_DESCR_PROPS_CONFIGURATION sizeof(usbDescriptorConfiguration)
PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor */
PROGMEM const char usbDescriptorConfiguration[] = { /* USB configuration descriptor */
9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
USBDESCR_CONFIG, /* descriptor type */
18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 +
@ -498,7 +498,8 @@ static uchar usbDeviceRead(uchar *data, uchar len)
}else
#endif
{
uchar i = len, *r = usbMsgPtr;
uchar i = len;
const uchar *r = usbMsgPtr;
if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */
do{
uchar c = USB_READ_FLASH(r); /* assign to char size variable to enforce byte ops */

View File

@ -178,7 +178,7 @@ USB_PUBLIC void usbPoll(void);
* Please note that debug outputs through the UART take ~ 0.5ms per byte
* at 19200 bps.
*/
extern uchar *usbMsgPtr;
extern const uchar *usbMsgPtr;
/* This variable may be used to pass transmit data to the driver from the
* implementation of usbFunctionWrite(). It is also used internally by the
* driver for standard control requests.
@ -452,43 +452,43 @@ extern
#if !(USB_CFG_DESCR_PROPS_DEVICE & USB_PROP_IS_RAM)
PROGMEM
#endif
char usbDescriptorDevice[];
const char usbDescriptorDevice[];
extern
#if !(USB_CFG_DESCR_PROPS_CONFIGURATION & USB_PROP_IS_RAM)
PROGMEM
#endif
char usbDescriptorConfiguration[];
const char usbDescriptorConfiguration[];
extern
#if !(USB_CFG_DESCR_PROPS_HID_REPORT & USB_PROP_IS_RAM)
PROGMEM
#endif
char usbDescriptorHidReport[];
const char usbDescriptorHidReport[];
extern
#if !(USB_CFG_DESCR_PROPS_STRING_0 & USB_PROP_IS_RAM)
PROGMEM
#endif
char usbDescriptorString0[];
const char usbDescriptorString0[];
extern
#if !(USB_CFG_DESCR_PROPS_STRING_VENDOR & USB_PROP_IS_RAM)
PROGMEM
#endif
int usbDescriptorStringVendor[];
const int usbDescriptorStringVendor[];
extern
#if !(USB_CFG_DESCR_PROPS_STRING_PRODUCT & USB_PROP_IS_RAM)
PROGMEM
#endif
int usbDescriptorStringDevice[];
const int usbDescriptorStringDevice[];
extern
#if !(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER & USB_PROP_IS_RAM)
PROGMEM
#endif
int usbDescriptorStringSerialNumber[];
const int usbDescriptorStringSerialNumber[];
#endif /* __ASSEMBLER__ */

View File

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "debug.h"
#include "host_driver.h"
#include "vusb.h"
#include "action_util.h"
static uint8_t vusb_keyboard_leds = 0;
@ -232,7 +233,7 @@ uchar usbFunctionWrite(uchar *data, uchar len)
*
* from an example in HID spec appendix
*/
PROGMEM uchar keyboard_hid_report[] = {
PROGMEM const uchar keyboard_hid_report[] = {
0x05, 0x01, // Usage Page (Generic Desktop),
0x09, 0x06, // Usage (Keyboard),
0xA1, 0x01, // Collection (Application),
@ -275,7 +276,7 @@ PROGMEM uchar keyboard_hid_report[] = {
* http://www.keil.com/forum/15671/
* http://www.microsoft.com/whdc/device/input/wheel.mspx
*/
PROGMEM uchar mouse_hid_report[] = {
PROGMEM const uchar mouse_hid_report[] = {
/* mouse */
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x02, // USAGE (Mouse)
@ -358,7 +359,7 @@ PROGMEM uchar mouse_hid_report[] = {
* contains: device, interface, HID and endpoint descriptors
*/
#if USB_CFG_DESCR_PROPS_CONFIGURATION
PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor */
PROGMEM const char usbDescriptorConfiguration[] = { /* USB configuration descriptor */
9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
USBDESCR_CONFIG, /* descriptor type */
9 + (9 + 9 + 7) + (9 + 9 + 7), 0,