indent cleanup
This commit is contained in:
parent
0f0c6eb409
commit
c09d1a1918
@ -115,16 +115,23 @@ void boot_startup_rom(uint16_t init_delay)
|
||||
info_P(PSTR("\n"));
|
||||
}
|
||||
|
||||
void banner(){
|
||||
void banner()
|
||||
{
|
||||
uint8_t i;
|
||||
for (i = 0; i < 40; i++)
|
||||
info_P(PSTR("\n"));
|
||||
info_P(PSTR(" ________ .__ __ ________ ____ ________\n"));
|
||||
info_P(PSTR(" \\_____ \\ __ __|__| ____ | | __\\______ \\ _______ _/_ |/ _____/\n"));
|
||||
info_P(PSTR(" / / \\ \\| | \\ |/ ___\\| |/ / | | \\_/ __ \\ \\/ /| / __ \\ \n"));
|
||||
info_P(PSTR(" / \\_/. \\ | / \\ \\___| < | ` \\ ___/\\ / | \\ |__\\ \\ \n"));
|
||||
info_P(PSTR(" \\_____\\ \\_/____/|__|\\___ >__|_ \\/_______ /\\___ >\\_/ |___|\\_____ / \n"));
|
||||
info_P(PSTR(" \\__> \\/ \\/ \\/ \\/ \\/ \n"));
|
||||
info_P(PSTR
|
||||
(" ________ .__ __ ________ ____ ________\n"));
|
||||
info_P(PSTR
|
||||
(" \\_____ \\ __ __|__| ____ | | __\\______ \\ _______ _/_ |/ _____/\n"));
|
||||
info_P(PSTR
|
||||
(" / / \\ \\| | \\ |/ ___\\| |/ / | | \\_/ __ \\ \\/ /| / __ \\ \n"));
|
||||
info_P(PSTR
|
||||
(" / \\_/. \\ | / \\ \\___| < | ` \\ ___/\\ / | \\ |__\\ \\ \n"));
|
||||
info_P(PSTR
|
||||
(" \\_____\\ \\_/____/|__|\\___ >__|_ \\/_______ /\\___ >\\_/ |___|\\_____ / \n"));
|
||||
info_P(PSTR
|
||||
(" \\__> \\/ \\/ \\/ \\/ \\/ \n"));
|
||||
info_P(PSTR("\n"));
|
||||
info_P(PSTR(" www.optixx.org\n"));
|
||||
info_P(PSTR("\n"));
|
||||
@ -132,7 +139,8 @@ void banner(){
|
||||
|
||||
}
|
||||
|
||||
void transaction_status(){
|
||||
void transaction_status()
|
||||
{
|
||||
info_P(PSTR("\nAddr 0x%06lx\n"), usb_trans.req_addr);
|
||||
info_P(PSTR("Bank 0x%02x\n"), usb_trans.req_bank);
|
||||
info_P(PSTR("Banksize 0x%06lx\n"), usb_trans.req_bank_size);
|
||||
@ -143,4 +151,3 @@ void transaction_status(){
|
||||
info_P(PSTR("RX buffer %02i\n"), usb_trans.rx_remaining);
|
||||
info_P(PSTR("Syncerr %02i\n"), usb_trans.sync_errors);
|
||||
}
|
||||
|
||||
|
||||
@ -65,18 +65,23 @@ uint16_t do_crc_update(uint16_t crc, uint8_t * data, uint16_t size)
|
||||
}
|
||||
|
||||
|
||||
uint16_t crc_check_bulk_memory(uint32_t bottom_addr, uint32_t top_addr, uint32_t bank_size)
|
||||
uint16_t crc_check_bulk_memory(uint32_t bottom_addr, uint32_t top_addr,
|
||||
uint32_t bank_size)
|
||||
{
|
||||
uint16_t crc = 0;
|
||||
uint32_t addr = 0;
|
||||
uint8_t req_bank = 0;
|
||||
sram_bulk_read_start(bottom_addr);
|
||||
debug_P(DEBUG_CRC, PSTR("crc_check_bulk_memory: bottom_addr=0x%08lx top_addr=0x%08lx\n"),
|
||||
debug_P(DEBUG_CRC,
|
||||
PSTR
|
||||
("crc_check_bulk_memory: bottom_addr=0x%08lx top_addr=0x%08lx\n"),
|
||||
bottom_addr, top_addr);
|
||||
|
||||
for (addr = bottom_addr; addr < top_addr; addr++) {
|
||||
if (addr && ((addr % bank_size) == 0)) {
|
||||
debug_P(DEBUG_CRC, PSTR("crc_check_bulk_memory: bank=0x%02x addr=0x%08lx crc=0x%04x\n"),
|
||||
debug_P(DEBUG_CRC,
|
||||
PSTR
|
||||
("crc_check_bulk_memory: bank=0x%02x addr=0x%08lx crc=0x%04x\n"),
|
||||
req_bank, addr, crc);
|
||||
req_bank++;
|
||||
crc = 0;
|
||||
@ -85,7 +90,9 @@ uint16_t crc_check_bulk_memory(uint32_t bottom_addr, uint32_t top_addr, uint32_t
|
||||
sram_bulk_read_next();
|
||||
}
|
||||
if (addr % 0x8000 == 0)
|
||||
debug_P(DEBUG_CRC, PSTR("crc_check_bulk_memory: bank=0x%02x addr=0x%08lx crc=0x%04x\n"),
|
||||
debug_P(DEBUG_CRC,
|
||||
PSTR
|
||||
("crc_check_bulk_memory: bank=0x%02x addr=0x%08lx crc=0x%04x\n"),
|
||||
req_bank, addr, crc);
|
||||
sram_bulk_read_end();
|
||||
return crc;
|
||||
@ -94,11 +101,13 @@ uint16_t crc_check_bulk_memory(uint32_t bottom_addr, uint32_t top_addr, uint32_t
|
||||
|
||||
|
||||
|
||||
uint16_t crc_check_memory_range(uint32_t start_addr, uint32_t size,uint8_t *buffer)
|
||||
uint16_t crc_check_memory_range(uint32_t start_addr, uint32_t size,
|
||||
uint8_t * buffer)
|
||||
{
|
||||
uint16_t crc = 0;
|
||||
uint32_t addr;
|
||||
for (addr = start_addr; addr < start_addr + size; addr += TRANSFER_BUFFER_SIZE) {
|
||||
for (addr = start_addr; addr < start_addr + size;
|
||||
addr += TRANSFER_BUFFER_SIZE) {
|
||||
sram_bulk_copy_into_buffer(addr, buffer, TRANSFER_BUFFER_SIZE);
|
||||
crc = do_crc_update(crc, buffer, TRANSFER_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
@ -29,7 +29,9 @@
|
||||
uint16_t crc_xmodem_update(uint16_t crc, uint8_t data);
|
||||
uint16_t do_crc(uint8_t * data, uint16_t size);
|
||||
uint16_t do_crc_update(uint16_t crc, uint8_t * data, uint16_t size);
|
||||
uint16_t crc_check_memory_range(uint32_t start_addr, uint32_t size,uint8_t *buffer);
|
||||
uint16_t crc_check_bulk_memory(uint32_t bottom_addr, uint32_t bank_size,uint32_t top_addr);
|
||||
uint16_t crc_check_memory_range(uint32_t start_addr, uint32_t size,
|
||||
uint8_t * buffer);
|
||||
uint16_t crc_check_bulk_memory(uint32_t bottom_addr, uint32_t bank_size,
|
||||
uint32_t top_addr);
|
||||
|
||||
#endif
|
||||
|
||||
@ -32,7 +32,8 @@ extern int debug_level; /* the higher, the more messages... */
|
||||
|
||||
#if defined(NO_DEBUG) && defined(__GNUC__)
|
||||
#else
|
||||
void debug(int level, char* format, ...) {
|
||||
void debug(int level, char *format, ...)
|
||||
{
|
||||
#ifdef NO_DEBUG
|
||||
|
||||
#else
|
||||
@ -52,7 +53,8 @@ void debug(int level, char* format, ...) {
|
||||
|
||||
#if defined(NO_DEBUG) && defined(__GNUC__)
|
||||
#else
|
||||
void debug_P(int level, PGM_P format, ...) {
|
||||
void debug_P(int level, PGM_P format, ...)
|
||||
{
|
||||
#ifdef NO_DEBUG
|
||||
|
||||
#else
|
||||
@ -66,4 +68,3 @@ void debug_P(int level, PGM_P format, ...) {
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -29,27 +29,30 @@
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#if defined(NO_DEBUG) && defined(__GNUC__)
|
||||
/* gcc's cpp has extensions; it allows for macros with a variable number of
|
||||
arguments. We use this extension here to preprocess pmesg away. */
|
||||
/*
|
||||
* gcc's cpp has extensions; it allows for macros with a variable number of arguments. We use this extension here to preprocess pmesg away.
|
||||
*/
|
||||
#define debug(level, format, args...) ((void)0)
|
||||
#else
|
||||
void debug(int level, char *format, ...);
|
||||
/* print a message, if it is considered significant enough.
|
||||
Adapted from [K&R2], p. 174 */
|
||||
/*
|
||||
* print a message, if it is considered significant enough. Adapted from [K&R2], p. 174
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(NO_DEBUG) && defined(__GNUC__)
|
||||
/* gcc's cpp has extensions; it allows for macros with a variable number of
|
||||
arguments. We use this extension here to preprocess pmesg away. */
|
||||
/*
|
||||
* gcc's cpp has extensions; it allows for macros with a variable number of arguments. We use this extension here to preprocess pmesg away.
|
||||
*/
|
||||
#define debug_P(level, format, args...) ((void)0)
|
||||
#else
|
||||
void debug_P(int level, PGM_P format, ...);
|
||||
/* print a message, if it is considered significant enough.
|
||||
Adapted from [K&R2], p. 174 */
|
||||
/*
|
||||
* print a message, if it is considered significant enough. Adapted from [K&R2], p. 174
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* DEBUG_H */
|
||||
|
||||
|
||||
@ -31,4 +31,3 @@ void dump_memory(uint32_t bottom_addr, uint32_t top_addr);
|
||||
void dump_packet(uint32_t addr, uint32_t len, uint8_t * packet);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -37,7 +37,8 @@ extern FILE uart_stdout;
|
||||
#define info(format, args...) ((void)0)
|
||||
|
||||
#else
|
||||
void info(char* format, ...) {
|
||||
void info(char *format, ...)
|
||||
{
|
||||
#ifdef NO_INFO
|
||||
|
||||
#else
|
||||
@ -59,7 +60,8 @@ void info(char* format, ...) {
|
||||
#define info(format, args...) ((void)0)
|
||||
|
||||
#else
|
||||
void info_P(PGM_P format, ...) {
|
||||
void info_P(PGM_P format, ...)
|
||||
{
|
||||
#ifdef NO_INFO
|
||||
|
||||
#else
|
||||
@ -71,4 +73,3 @@ void info_P(PGM_P format, ...) {
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -29,24 +29,28 @@
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#if defined(NO_INFO) && defined(__GNUC__)
|
||||
/* gcc's cpp has extensions; it allows for macros with a variable number of
|
||||
arguments. We use this extension here to preprocess pmesg away. */
|
||||
/*
|
||||
* gcc's cpp has extensions; it allows for macros with a variable number of arguments. We use this extension here to preprocess pmesg away.
|
||||
*/
|
||||
#define info(format, args...) ((void)0)
|
||||
#else
|
||||
void info(char *format, ...);
|
||||
/* print a message, if it is considered significant enough.
|
||||
Adapted from [K&R2], p. 174 */
|
||||
/*
|
||||
* print a message, if it is considered significant enough. Adapted from [K&R2], p. 174
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(NO_INFO) && defined(__GNUC__)
|
||||
/* gcc's cpp has extensions; it allows for macros with a variable number of
|
||||
arguments. We use this extension here to preprocess pmesg away. */
|
||||
/*
|
||||
* gcc's cpp has extensions; it allows for macros with a variable number of arguments. We use this extension here to preprocess pmesg away.
|
||||
*/
|
||||
#define info_P(format, args...) ((void)0)
|
||||
#else
|
||||
void info_P(PGM_P format, ...);
|
||||
/* print a message, if it is considered significant enough.
|
||||
Adapted from [K&R2], p. 174 */
|
||||
/*
|
||||
* print a message, if it is considered significant enough. Adapted from [K&R2], p. 174
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -29,8 +29,7 @@
|
||||
|
||||
|
||||
#include "usbdrv.h"
|
||||
#include "oddebug.h" /* This is also an example for using debug
|
||||
* macros */
|
||||
#include "oddebug.h" /* This is also an example for using debug macros */
|
||||
#include "debug.h"
|
||||
#include "info.h"
|
||||
#include "sram.h"
|
||||
@ -40,7 +39,8 @@ extern system_t system;
|
||||
|
||||
void (*jump_to_app) (void) = 0x0000;
|
||||
|
||||
void irq_init(){
|
||||
void irq_init()
|
||||
{
|
||||
cli();
|
||||
PCMSK3 |= (1 << PCINT27);
|
||||
PCICR |= (1 << PCIE3);
|
||||
@ -48,7 +48,8 @@ void irq_init(){
|
||||
system.reset_irq = RESET_IRQ_ON;
|
||||
}
|
||||
|
||||
void irq_stop(){
|
||||
void irq_stop()
|
||||
{
|
||||
cli();
|
||||
PCMSK3 &= ~(1 << PCINT27);
|
||||
sei();
|
||||
@ -73,4 +74,3 @@ ISR (SIG_PIN_CHANGE3)
|
||||
leave_application();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
5832
avr/usbload/loader.c
5832
avr/usbload/loader.c
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,5 @@
|
||||
/*
|
||||
File: qd16boot01.smc
|
||||
Time: Fri, 30 Oct 2009 16:49:11
|
||||
* File: qd16boot01.smc Time: Fri, 30 Oct 2009 16:49:11
|
||||
*/
|
||||
#ifndef __FIFO_H__
|
||||
#define __FIFO_H__
|
||||
|
||||
@ -70,20 +70,24 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
|
||||
usb_trans.req_bank = 0;
|
||||
usb_trans.rx_remaining = 0;
|
||||
debug_P(DEBUG_USB, PSTR("USB_BULK_UPLOAD_INIT: %i %i\n"), rq->wValue.word,
|
||||
rq->wIndex.word);
|
||||
debug_P(DEBUG_USB, PSTR("USB_BULK_UPLOAD_INIT: %i %i\n"),
|
||||
rq->wValue.word, rq->wIndex.word);
|
||||
usb_trans.req_bank_size = (uint32_t) (1L << rq->wValue.word);
|
||||
usb_trans.req_bank_cnt = rq->wIndex.word;
|
||||
usb_trans.req_addr_end = (uint32_t) usb_trans.req_bank_size * usb_trans.req_bank_cnt;
|
||||
usb_trans.req_addr_end =
|
||||
(uint32_t) usb_trans.req_bank_size * usb_trans.req_bank_cnt;
|
||||
usb_trans.req_percent = 0;
|
||||
usb_trans.req_percent_last = 0;
|
||||
usb_trans.sync_errors = 0;
|
||||
debug_P(DEBUG_USB,
|
||||
PSTR("USB_BULK_UPLOAD_INIT: bank_size=0x%08lx bank_cnt=0x%x end_addr=0x%08lx\n"),
|
||||
usb_trans.req_bank_size, usb_trans.req_bank_cnt, usb_trans.req_addr_end);
|
||||
PSTR
|
||||
("USB_BULK_UPLOAD_INIT: bank_size=0x%08lx bank_cnt=0x%x end_addr=0x%08lx\n"),
|
||||
usb_trans.req_bank_size, usb_trans.req_bank_cnt,
|
||||
usb_trans.req_addr_end);
|
||||
|
||||
shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_START, 0);
|
||||
shared_memory_write(SHARED_MEM_TX_CMD_BANK_COUNT, usb_trans.req_bank_cnt);
|
||||
shared_memory_write(SHARED_MEM_TX_CMD_BANK_COUNT,
|
||||
usb_trans.req_bank_cnt);
|
||||
#if DO_TIMER
|
||||
if (usb_trans.req_addr == 0x000000) {
|
||||
#ifndef NO_DEBUG
|
||||
@ -104,16 +108,19 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
|
||||
|
||||
|
||||
if (usb_trans.req_addr && usb_trans.req_addr % usb_trans.req_bank_size == 0) {
|
||||
if (usb_trans.req_addr
|
||||
&& usb_trans.req_addr % usb_trans.req_bank_size == 0) {
|
||||
#if DO_TIMER
|
||||
#ifndef NO_DEBUG
|
||||
#ifdef FLT_DEBUG
|
||||
debug_P(DEBUG_USB,
|
||||
PSTR("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
|
||||
PSTR
|
||||
("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
|
||||
usb_trans.req_bank, usb_trans.req_addr, timer_stop());
|
||||
#else
|
||||
debug_P(DEBUG_USB,
|
||||
PSTR("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%i\n"),
|
||||
PSTR
|
||||
("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%i\n"),
|
||||
usb_trans.req_bank, usb_trans.req_addr, timer_stop_int());
|
||||
#endif
|
||||
timer_start();
|
||||
@ -137,23 +144,28 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
usb_trans.rx_remaining = rq->wLength.word;
|
||||
|
||||
#if DO_SHM
|
||||
usb_trans.req_percent = (uint32_t)( 100 * usb_trans.req_addr ) / usb_trans.req_addr_end;
|
||||
usb_trans.req_percent =
|
||||
(uint32_t) (100 * usb_trans.req_addr) / usb_trans.req_addr_end;
|
||||
if (usb_trans.req_percent != usb_trans.req_percent_last) {
|
||||
shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_PROGESS, usb_trans.req_percent);
|
||||
shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_PROGESS,
|
||||
usb_trans.req_percent);
|
||||
}
|
||||
usb_trans.req_percent_last = usb_trans.req_percent;
|
||||
shared_memory_scratchpad_region_save_helper(usb_trans.req_addr);
|
||||
#endif
|
||||
if (usb_trans.req_addr && (usb_trans.req_addr % usb_trans.req_bank_size) == 0) {
|
||||
if (usb_trans.req_addr
|
||||
&& (usb_trans.req_addr % usb_trans.req_bank_size) == 0) {
|
||||
#if DO_TIMER
|
||||
#ifndef NO_DEBUG
|
||||
#ifdef FLT_DEBUG
|
||||
debug_P(DEBUG_USB,
|
||||
PSTR("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
|
||||
PSTR
|
||||
("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
|
||||
usb_trans.req_bank, usb_trans.req_addr, timer_stop());
|
||||
#else
|
||||
debug_P(DEBUG_USB,
|
||||
PSTR("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%i\n"),
|
||||
PSTR
|
||||
("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%i\n"),
|
||||
usb_trans.req_bank, usb_trans.req_addr, timer_stop_int());
|
||||
#endif
|
||||
timer_start();
|
||||
@ -161,7 +173,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
#endif
|
||||
usb_trans.req_bank++;
|
||||
#if DO_SHM
|
||||
shared_memory_write(SHARED_MEM_TX_CMD_BANK_CURRENT, usb_trans.req_bank);
|
||||
shared_memory_write(SHARED_MEM_TX_CMD_BANK_CURRENT,
|
||||
usb_trans.req_bank);
|
||||
#endif
|
||||
}
|
||||
ret_len = USB_MAX_TRANS;
|
||||
@ -184,8 +197,10 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
usb_trans.req_addr = rq->wValue.word;
|
||||
usb_trans.req_addr = usb_trans.req_addr << 16;
|
||||
usb_trans.req_addr = usb_trans.req_addr | rq->wIndex.word;
|
||||
debug_P(DEBUG_USB, PSTR("USB_CRC: addr=0x%08lx \n"), usb_trans.req_addr);
|
||||
crc_check_bulk_memory(0x000000, usb_trans.req_addr, usb_trans.req_bank_size);
|
||||
debug_P(DEBUG_USB, PSTR("USB_CRC: addr=0x%08lx \n"),
|
||||
usb_trans.req_addr);
|
||||
crc_check_bulk_memory(0x000000, usb_trans.req_addr,
|
||||
usb_trans.req_bank_size);
|
||||
ret_len = 0;
|
||||
/*
|
||||
* -------------------------------------------------------------------------
|
||||
@ -226,7 +241,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
*/
|
||||
|
||||
|
||||
void globals_init(){
|
||||
void globals_init()
|
||||
{
|
||||
memset(&usb_trans, 0, sizeof(usb_transaction_t));
|
||||
|
||||
usb_trans.req_addr = 0;
|
||||
@ -280,7 +296,9 @@ int main(void)
|
||||
|
||||
#if DO_CRC_CHECK
|
||||
info_P(PSTR("-->CRC Check\n"));
|
||||
crc_check_bulk_memory(0x000000, usb_trans.req_bank_size * usb_trans.req_bank_cnt, usb_trans.req_bank_size);
|
||||
crc_check_bulk_memory(0x000000,
|
||||
usb_trans.req_bank_size * usb_trans.req_bank_cnt,
|
||||
usb_trans.req_bank_size);
|
||||
#endif
|
||||
|
||||
system_set_rom_mode(&usb_trans);
|
||||
|
||||
@ -32,10 +32,14 @@
|
||||
#define PWM_OVERFLOW_MAX 1024
|
||||
|
||||
uint8_t pwm_sine_table[] = {
|
||||
0x7f,0x8b,0x97,0xa4,0xaf,0xbb,0xc5,0xcf,0xd9,0xe1,0xe8,0xef,0xf4,0xf8,0xfb,0xfd,
|
||||
0xfd,0xfd,0xfb,0xf8,0xf3,0xee,0xe7,0xe0,0xd7,0xce,0xc4,0xb9,0xae,0xa2,0x96,0x89,
|
||||
0x7e,0x71,0x65,0x59,0x4d,0x42,0x37,0x2d,0x24,0x1c,0x15,0x0f,0x09,0x05,0x03,0x01,
|
||||
0x01,0x01,0x03,0x07,0x0b,0x11,0x17,0x1f,0x28,0x31,0x3b,0x46,0x52,0x5e,0x6a,0x76
|
||||
0x7f, 0x8b, 0x97, 0xa4, 0xaf, 0xbb, 0xc5, 0xcf, 0xd9, 0xe1, 0xe8, 0xef,
|
||||
0xf4, 0xf8, 0xfb, 0xfd,
|
||||
0xfd, 0xfd, 0xfb, 0xf8, 0xf3, 0xee, 0xe7, 0xe0, 0xd7, 0xce, 0xc4, 0xb9,
|
||||
0xae, 0xa2, 0x96, 0x89,
|
||||
0x7e, 0x71, 0x65, 0x59, 0x4d, 0x42, 0x37, 0x2d, 0x24, 0x1c, 0x15, 0x0f,
|
||||
0x09, 0x05, 0x03, 0x01,
|
||||
0x01, 0x01, 0x03, 0x07, 0x0b, 0x11, 0x17, 0x1f, 0x28, 0x31, 0x3b, 0x46,
|
||||
0x52, 0x5e, 0x6a, 0x76
|
||||
};
|
||||
|
||||
volatile uint8_t pwm_setting;
|
||||
@ -43,7 +47,8 @@ volatile uint16_t pwm_overflow;
|
||||
volatile uint8_t pwm_idx;
|
||||
volatile uint16_t pwm_overflow_max;
|
||||
|
||||
ISR(TIMER2_COMPA_vect) {
|
||||
ISR(TIMER2_COMPA_vect)
|
||||
{
|
||||
static uint8_t pwm_cnt = 0;
|
||||
OCR2A += (uint16_t) T_PWM;
|
||||
|
||||
@ -64,33 +69,40 @@ volatile uint16_t pwm_overflow_max;
|
||||
}
|
||||
}
|
||||
|
||||
void pwm_speed(uint16_t val) {
|
||||
void pwm_speed(uint16_t val)
|
||||
{
|
||||
pwm_overflow_max = val;
|
||||
}
|
||||
|
||||
void pwm_speed_slow(uint16_t val) {
|
||||
void pwm_speed_slow(uint16_t val)
|
||||
{
|
||||
pwm_overflow_max = PWM_OVERFLOW_MAX * 2;
|
||||
}
|
||||
|
||||
void pwm_speed_fast(uint16_t val) {
|
||||
void pwm_speed_fast(uint16_t val)
|
||||
{
|
||||
pwm_overflow_max = PWM_OVERFLOW_MAX / 2;
|
||||
}
|
||||
|
||||
void pwm_speed_normal(uint16_t val) {
|
||||
void pwm_speed_normal(uint16_t val)
|
||||
{
|
||||
pwm_overflow_max = PWM_OVERFLOW_MAX;
|
||||
}
|
||||
|
||||
|
||||
void pwm_set(uint8_t val) {
|
||||
void pwm_set(uint8_t val)
|
||||
{
|
||||
pwm_setting = val;
|
||||
}
|
||||
|
||||
void pwm_stop(void) {
|
||||
void pwm_stop(void)
|
||||
{
|
||||
while (pwm_setting != 0xfd);
|
||||
TIMSK2 = 0;
|
||||
}
|
||||
|
||||
void pwm_init(void) {
|
||||
void pwm_init(void)
|
||||
{
|
||||
pwm_overflow_max = PWM_OVERFLOW_MAX;
|
||||
pwm_setting = 0x7f;
|
||||
pwm_overflow = 0;
|
||||
|
||||
@ -48,25 +48,35 @@ uint8_t scratchpad_locked_rx = 1;
|
||||
uint8_t scratchpad_locked_tx = 1;
|
||||
|
||||
|
||||
void shared_memory_init(void){
|
||||
void shared_memory_init(void)
|
||||
{
|
||||
scratchpad_locked_rx = 1;
|
||||
scratchpad_locked_tx = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
uint8_t shared_memory_scratchpad_region_save_helper(uint32_t addr){
|
||||
uint8_t shared_memory_scratchpad_region_save_helper(uint32_t addr)
|
||||
{
|
||||
|
||||
|
||||
|
||||
#if DO_SHM_SCRATCHPAD
|
||||
if(addr > (SHARED_MEM_TX_LOC_STATE + (SHARED_MEM_TX_LOC_SIZE )) && scratchpad_locked_tx){
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_save_helper: open tx addr=0x%06lx\n"),addr);
|
||||
if (addr > (SHARED_MEM_TX_LOC_STATE + (SHARED_MEM_TX_LOC_SIZE))
|
||||
&& scratchpad_locked_tx) {
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR
|
||||
("shared_memory_scratchpad_region_save_helper: open tx addr=0x%06lx\n"),
|
||||
addr);
|
||||
shared_memory_scratchpad_region_tx_save();
|
||||
return 0;
|
||||
}
|
||||
if(addr > (SHARED_MEM_RX_LOC_STATE + ( SHARED_MEM_RX_LOC_SIZE )) && scratchpad_locked_rx){
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_save_helper: open rx addr=0x%06lx\n"),addr);
|
||||
if (addr > (SHARED_MEM_RX_LOC_STATE + (SHARED_MEM_RX_LOC_SIZE))
|
||||
&& scratchpad_locked_rx) {
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR
|
||||
("shared_memory_scratchpad_region_save_helper: open rx addr=0x%06lx\n"),
|
||||
addr);
|
||||
shared_memory_scratchpad_region_rx_save();
|
||||
return 0;
|
||||
}
|
||||
@ -82,24 +92,31 @@ void shared_memory_scratchpad_region_tx_save()
|
||||
#if SHARED_SCRATCHPAD_CRC
|
||||
uint16_t crc;
|
||||
crc = crc_check_bulk_memory((uint32_t) SHARED_MEM_TX_LOC_STATE,
|
||||
(uint32_t)(SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE), 0x8000);
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_save: crc=%x\n"),crc);
|
||||
(uint32_t) (SHARED_MEM_TX_LOC_STATE +
|
||||
SHARED_MEM_TX_LOC_SIZE), 0x8000);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_tx_save: crc=%x\n"), crc);
|
||||
|
||||
#endif
|
||||
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_save: unlock\n"));
|
||||
sram_bulk_copy_into_buffer((uint32_t)SHARED_MEM_TX_LOC_STATE,scratchpad_region_tx,
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_tx_save: unlock\n"));
|
||||
sram_bulk_copy_into_buffer((uint32_t) SHARED_MEM_TX_LOC_STATE,
|
||||
scratchpad_region_tx,
|
||||
(uint32_t) SHARED_MEM_TX_LOC_SIZE);
|
||||
scratchpad_locked_tx = 0;
|
||||
|
||||
#if SHARED_SCRATCHPAD_CRC
|
||||
do_crc_update(0, scratchpad_region_tx, SHARED_MEM_TX_LOC_SIZE);
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_save: crc=%x\n"),crc);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_tx_save: crc=%x\n"), crc);
|
||||
#endif
|
||||
|
||||
#if SHARED_SCRATCHPAD_DUMP
|
||||
dump_packet(SHARED_MEM_TX_LOC_STATE, SHARED_MEM_TX_LOC_SIZE, scratchpad_region_tx);
|
||||
dump_memory(SHARED_MEM_TX_LOC_STATE, SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE);
|
||||
dump_packet(SHARED_MEM_TX_LOC_STATE, SHARED_MEM_TX_LOC_SIZE,
|
||||
scratchpad_region_tx);
|
||||
dump_memory(SHARED_MEM_TX_LOC_STATE,
|
||||
SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE);
|
||||
#endif
|
||||
sram_bulk_addr_restore();
|
||||
|
||||
@ -112,23 +129,30 @@ void shared_memory_scratchpad_region_rx_save()
|
||||
#if SHARED_SCRATCHPAD_CRC
|
||||
uint16_t crc;
|
||||
crc = crc_check_bulk_memory((uint32_t) SHARED_MEM_RX_LOC_STATE,
|
||||
(uint32_t)(SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE), 0x8000);
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_rx_save: crc=%x\n"),crc);
|
||||
(uint32_t) (SHARED_MEM_RX_LOC_STATE +
|
||||
SHARED_MEM_RX_LOC_SIZE), 0x8000);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_rx_save: crc=%x\n"), crc);
|
||||
#endif
|
||||
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_rx_save: unlock\n"));
|
||||
sram_bulk_copy_into_buffer((uint32_t)SHARED_MEM_RX_LOC_STATE,scratchpad_region_rx,
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_rx_save: unlock\n"));
|
||||
sram_bulk_copy_into_buffer((uint32_t) SHARED_MEM_RX_LOC_STATE,
|
||||
scratchpad_region_rx,
|
||||
(uint32_t) SHARED_MEM_RX_LOC_SIZE);
|
||||
scratchpad_locked_rx = 0;
|
||||
|
||||
#if SHARED_SCRATCHPAD_CRC
|
||||
do_crc_update(0, scratchpad_region_rx, SHARED_MEM_RX_LOC_SIZE);
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_rx_save: crc=%x\n"),crc);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_rx_save: crc=%x\n"), crc);
|
||||
#endif
|
||||
|
||||
#if SHARED_SCRATCHPAD_DUMP
|
||||
dump_packet(SHARED_MEM_RX_LOC_STATE, SHARED_MEM_RX_LOC_SIZE, scratchpad_region_rx);
|
||||
dump_memory(SHARED_MEM_RX_LOC_STATE, SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE);
|
||||
dump_packet(SHARED_MEM_RX_LOC_STATE, SHARED_MEM_RX_LOC_SIZE,
|
||||
scratchpad_region_rx);
|
||||
dump_memory(SHARED_MEM_RX_LOC_STATE,
|
||||
SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE);
|
||||
#endif
|
||||
sram_bulk_addr_restore();
|
||||
|
||||
@ -138,29 +162,39 @@ void shared_memory_scratchpad_region_tx_restore()
|
||||
{
|
||||
if (scratchpad_locked_tx)
|
||||
return;
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_restore: lock\n"));
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_tx_restore: lock\n"));
|
||||
|
||||
#if SHARED_SCRATCHPAD_DUMP
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_restore: memory\n"));
|
||||
dump_memory(SHARED_MEM_TX_LOC_STATE, SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_tx_restore: memory\n"));
|
||||
dump_memory(SHARED_MEM_TX_LOC_STATE,
|
||||
SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE);
|
||||
#endif
|
||||
|
||||
sram_bulk_copy_from_buffer((uint32_t)SHARED_MEM_TX_LOC_STATE,scratchpad_region_tx,
|
||||
sram_bulk_copy_from_buffer((uint32_t) SHARED_MEM_TX_LOC_STATE,
|
||||
scratchpad_region_tx,
|
||||
(uint32_t) SHARED_MEM_TX_LOC_SIZE);
|
||||
scratchpad_locked_tx = 1;
|
||||
|
||||
#if SHARED_SCRATCHPAD_DUMP
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_restore: buffer\n"));
|
||||
dump_packet(SHARED_MEM_TX_LOC_STATE, SHARED_MEM_TX_LOC_SIZE, scratchpad_region_tx);
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_restore: memory\n"));
|
||||
dump_memory(SHARED_MEM_TX_LOC_STATE, SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_tx_restore: buffer\n"));
|
||||
dump_packet(SHARED_MEM_TX_LOC_STATE, SHARED_MEM_TX_LOC_SIZE,
|
||||
scratchpad_region_tx);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_tx_restore: memory\n"));
|
||||
dump_memory(SHARED_MEM_TX_LOC_STATE,
|
||||
SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE);
|
||||
#endif
|
||||
|
||||
#if SHARED_SCRATCHPAD_CRC
|
||||
uint16_t crc;
|
||||
crc = crc_check_bulk_memory((uint32_t) SHARED_MEM_TX_LOC_STATE,
|
||||
(uint32_t)(SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE), 0x8000);
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_restore: crc=%x\n"),crc);
|
||||
(uint32_t) (SHARED_MEM_TX_LOC_STATE +
|
||||
SHARED_MEM_TX_LOC_SIZE), 0x8000);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_tx_restore: crc=%x\n"), crc);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -171,29 +205,39 @@ void shared_memory_scratchpad_region_rx_restore()
|
||||
return;
|
||||
|
||||
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_rx_restore: lock\n"));
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_rx_restore: lock\n"));
|
||||
|
||||
#if SHARED_SCRATCHPAD_DUMP
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_rx_restore: memory\n"));
|
||||
dump_memory(SHARED_MEM_RX_LOC_STATE - 0x10, SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_rx_restore: memory\n"));
|
||||
dump_memory(SHARED_MEM_RX_LOC_STATE - 0x10,
|
||||
SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE);
|
||||
#endif
|
||||
|
||||
sram_bulk_copy_from_buffer((uint32_t)SHARED_MEM_RX_LOC_STATE,scratchpad_region_rx,
|
||||
sram_bulk_copy_from_buffer((uint32_t) SHARED_MEM_RX_LOC_STATE,
|
||||
scratchpad_region_rx,
|
||||
(uint32_t) SHARED_MEM_RX_LOC_SIZE);
|
||||
scratchpad_locked_rx = 1;
|
||||
|
||||
#if SHARED_SCRATCHPAD_DUMP
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_rx_restore: buffer\n"));
|
||||
dump_packet(SHARED_MEM_RX_LOC_STATE, SHARED_MEM_RX_LOC_SIZE, scratchpad_region_rx);
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_rx_restore: memory\n"));
|
||||
dump_memory(SHARED_MEM_RX_LOC_STATE - 0x10, SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_rx_restore: buffer\n"));
|
||||
dump_packet(SHARED_MEM_RX_LOC_STATE, SHARED_MEM_RX_LOC_SIZE,
|
||||
scratchpad_region_rx);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_rx_restore: memory\n"));
|
||||
dump_memory(SHARED_MEM_RX_LOC_STATE - 0x10,
|
||||
SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE);
|
||||
#endif
|
||||
|
||||
#if SHARED_SCRATCHPAD_CRC
|
||||
uint16_t crc;
|
||||
crc = crc_check_bulk_memory((uint32_t) SHARED_MEM_RX_LOC_STATE,
|
||||
(uint32_t)(SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE), 0x8000);
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_rx_restore: crc=%x\n"),crc);
|
||||
(uint32_t) (SHARED_MEM_RX_LOC_STATE +
|
||||
SHARED_MEM_RX_LOC_SIZE), 0x8000);
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_scratchpad_region_rx_restore: crc=%x\n"), crc);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -236,7 +280,8 @@ void shared_memory_write(uint8_t cmd, uint8_t value)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_write: 0x%04x=0x%02x 0x%04x=0x%02x \n"),
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_write: 0x%04x=0x%02x 0x%04x=0x%02x \n"),
|
||||
SHARED_MEM_TX_LOC_CMD, cmd, SHARED_MEM_TX_LOC_PAYLOAD, value);
|
||||
|
||||
sram_bulk_addr_save();
|
||||
@ -316,7 +361,8 @@ int shared_memory_read(uint8_t *cmd, uint8_t *len,uint8_t *buffer)
|
||||
|
||||
*cmd = sram_read(SHARED_MEM_RX_LOC_CMD);
|
||||
*len = sram_read(SHARED_MEM_RX_LOC_LEN);
|
||||
debug_P(DEBUG_SHM, PSTR("shared_memory_read: 0x%04x=0x%02x 0x%04x=0x%02x \n"),
|
||||
debug_P(DEBUG_SHM,
|
||||
PSTR("shared_memory_read: 0x%04x=0x%02x 0x%04x=0x%02x \n"),
|
||||
SHARED_MEM_RX_LOC_CMD, *cmd, SHARED_MEM_RX_LOC_LEN, *len);
|
||||
|
||||
sram_bulk_copy_into_buffer(SHARED_MEM_RX_LOC_PAYLOAD, buffer, *len);
|
||||
|
||||
@ -56,7 +56,9 @@
|
||||
#define SHARED_IRQ_LOC_LO 0x00fffe
|
||||
#define SHARED_IRQ_LOC_HI 0x00ffff
|
||||
|
||||
/* Use COP IRQ LOC for hooked IRQ handler */
|
||||
/*
|
||||
* Use COP IRQ LOC for hooked IRQ handler
|
||||
*/
|
||||
#define SHARED_IRQ_HANDLER_LO 0x0ffe4
|
||||
#define SHARED_IRQ_HANDLER_HI 0x0ffe5
|
||||
|
||||
|
||||
@ -154,7 +154,8 @@ static uint8_t get_int32(uint32_t *val)
|
||||
info_P(PSTR("Invalid argument (should be 0 or 1)!\n"));
|
||||
return -1;
|
||||
}
|
||||
void prompt(void){
|
||||
void prompt(void)
|
||||
{
|
||||
|
||||
uart_putc('\r');
|
||||
uart_putc('\n');
|
||||
@ -175,14 +176,17 @@ ISR(USART0_RX_vect)
|
||||
recv_buf[recv_counter] = UDR0;
|
||||
uart_putc(recv_buf[recv_counter]);
|
||||
if (recv_buf[recv_counter] == 0x0d) {
|
||||
/* recv_buf[recv_counter] = 0; */
|
||||
/*
|
||||
* recv_buf[recv_counter] = 0;
|
||||
*/
|
||||
cr = 1;
|
||||
recv_buf[++recv_counter] = '\0';
|
||||
recv_counter = 0;
|
||||
prompt();
|
||||
} else {
|
||||
// we accept backspace or delete
|
||||
if ((recv_buf[recv_counter] == 0x08 || recv_buf[recv_counter] == 0x7f) && recv_counter > 0) {
|
||||
if ((recv_buf[recv_counter] == 0x08 || recv_buf[recv_counter] == 0x7f)
|
||||
&& recv_counter > 0) {
|
||||
recv_counter--;
|
||||
} else {
|
||||
recv_counter++;
|
||||
@ -240,7 +244,8 @@ uint8_t cmdlist[][CMD_HELP] PROGMEM = {
|
||||
};
|
||||
|
||||
|
||||
void shell_help(void){
|
||||
void shell_help(void)
|
||||
{
|
||||
uint8_t i;
|
||||
info_P(PSTR("\n"));
|
||||
for (i = CMD_DUMP; i < CMD_HELP; i++) {
|
||||
@ -339,12 +344,18 @@ void shell_run(void)
|
||||
else
|
||||
offset = 0x0000;
|
||||
|
||||
info_P(PSTR("ABORT 0x%04x 0x%04x\n"), (0xFFE8 - offset),sram_read16_be(0xFFE8 - offset));
|
||||
info_P(PSTR("BRK 0x%04x 0x%04x\n"), (0xFFE6 - offset),sram_read16_be(0xFFE6 - offset));
|
||||
info_P(PSTR("COP 0x%04x 0x%04x\n"), (0xFFE4 - offset),sram_read16_be(0xFFE4 - offset));
|
||||
info_P(PSTR("IRQ 0x%04x 0x%04x\n"), (0xFFEE - offset),sram_read16_be(0xFFEE - offset));
|
||||
info_P(PSTR("NMI 0x%04x 0x%04x\n"), (0xFFEA - offset),sram_read16_be(0xFFEA - offset));
|
||||
info_P(PSTR("RES 0x%04x 0x%04x\n"), (0xFFFC - offset),sram_read16_be(0xFFFC - offset));
|
||||
info_P(PSTR("ABORT 0x%04x 0x%04x\n"), (0xFFE8 - offset),
|
||||
sram_read16_be(0xFFE8 - offset));
|
||||
info_P(PSTR("BRK 0x%04x 0x%04x\n"), (0xFFE6 - offset),
|
||||
sram_read16_be(0xFFE6 - offset));
|
||||
info_P(PSTR("COP 0x%04x 0x%04x\n"), (0xFFE4 - offset),
|
||||
sram_read16_be(0xFFE4 - offset));
|
||||
info_P(PSTR("IRQ 0x%04x 0x%04x\n"), (0xFFEE - offset),
|
||||
sram_read16_be(0xFFEE - offset));
|
||||
info_P(PSTR("NMI 0x%04x 0x%04x\n"), (0xFFEA - offset),
|
||||
sram_read16_be(0xFFEA - offset));
|
||||
info_P(PSTR("RES 0x%04x 0x%04x\n"), (0xFFFC - offset),
|
||||
sram_read16_be(0xFFFC - offset));
|
||||
|
||||
} else if (strcmp_P((char *) t, (PGM_P) cmdlist[CMD_DUMPHEADER]) == 0) {
|
||||
|
||||
@ -353,17 +364,13 @@ void shell_run(void)
|
||||
else
|
||||
offset = 0x0000;
|
||||
/*
|
||||
# $ffc0..$ffd4 => Name of the ROM, typically in ASCII, using spaces to pad the name to 21 bytes.
|
||||
# $ffd5 => ROM layout, typically $20 for LoROM, or $21 for HiROM. Add $10 for FastROM.
|
||||
# $ffd6 => Cartridge type, typically $00 for ROM only, or $02 for ROM with save-RAM.
|
||||
# $ffd7 => ROM size byte.
|
||||
# $ffd8 => RAM size byte.
|
||||
# $ffd9 => Country code, which selects the video in the emulator. Values $00, $01, $0d use NTSC. Values in range $02..$0c use PAL. Other values are invalid.
|
||||
# $ffda => Licensee code. If this value is $33, then the ROM has an extended header with ID at $ffb2..$ffb5.
|
||||
# $ffdb => Version number, typically $00.
|
||||
# $ffdc..$ffdd => Checksum complement, which is the bitwise-xor of the checksum and $ffff.
|
||||
# $ffde..$ffdf => SNES checksum, an unsigned 16-bit checksum of bytes.
|
||||
# $ffe0..$ffe3 => Unknown.
|
||||
* # $ffc0..$ffd4 => Name of the ROM, typically in ASCII, using spaces to pad the name to 21 bytes. # $ffd5 => ROM layout,
|
||||
* typically $20 for LoROM, or $21 for HiROM. Add $10 for FastROM. # $ffd6 => Cartridge type, typically $00 for ROM only, or $02
|
||||
* for ROM with save-RAM. # $ffd7 => ROM size byte. # $ffd8 => RAM size byte. # $ffd9 => Country code, which selects the video in
|
||||
* the emulator. Values $00, $01, $0d use NTSC. Values in range $02..$0c use PAL. Other values are invalid. # $ffda => Licensee
|
||||
* code. If this value is $33, then the ROM has an extended header with ID at $ffb2..$ffb5. # $ffdb => Version number, typically
|
||||
* $00. # $ffdc..$ffdd => Checksum complement, which is the bitwise-xor of the checksum and $ffff. # $ffde..$ffdf => SNES checksum,
|
||||
* an unsigned 16-bit checksum of bytes. # $ffe0..$ffe3 => Unknown.
|
||||
*/
|
||||
info_P(PSTR("NAME 0x%04x "), (0xffc0 - offset));
|
||||
for (arg1 = (0xffc0 - offset); arg1 < (0xffc0 - offset + 21); arg1++) {
|
||||
@ -428,7 +435,8 @@ void shell_run(void)
|
||||
break;
|
||||
}
|
||||
arg1 = (2 << (sram_read(0xffd7 - offset) - 1));
|
||||
info_P(PSTR("ROM 0x%04x %li MBit ( %li KiB)\n"), (0xffd7 - offset), (arg1 / 128), arg1);
|
||||
info_P(PSTR("ROM 0x%04x %li MBit ( %li KiB)\n"),
|
||||
(0xffd7 - offset), (arg1 / 128), arg1);
|
||||
arg1 = (2 << (sram_read(0xffd8 - offset) - 1));
|
||||
info_P(PSTR("RAM 0x%04x %li KiB\n"), (0xffd8 - offset), arg1);
|
||||
|
||||
@ -441,10 +449,14 @@ void shell_run(void)
|
||||
else
|
||||
info_P(PSTR("Unkown 0x%02x\n"), c);
|
||||
|
||||
info_P(PSTR("LIC 0x%04x 0x%02x\n"), (0xffda - offset),sram_read(0xffda - offset));
|
||||
info_P(PSTR("VER 0x%04x 0x%02x\n"), (0xffdb - offset),sram_read(0xffdb - offset));
|
||||
info_P(PSTR("SUM1 0x%04x 0x%04x\n"), (0xffdc - offset),sram_read16_be(0xffdc - offset));
|
||||
info_P(PSTR("SUM2 0x%04x 0x%04x\n"), (0xffde - offset),sram_read16_be(0xffde - offset));
|
||||
info_P(PSTR("LIC 0x%04x 0x%02x\n"), (0xffda - offset),
|
||||
sram_read(0xffda - offset));
|
||||
info_P(PSTR("VER 0x%04x 0x%02x\n"), (0xffdb - offset),
|
||||
sram_read(0xffdb - offset));
|
||||
info_P(PSTR("SUM1 0x%04x 0x%04x\n"), (0xffdc - offset),
|
||||
sram_read16_be(0xffdc - offset));
|
||||
info_P(PSTR("SUM2 0x%04x 0x%04x\n"), (0xffde - offset),
|
||||
sram_read16_be(0xffde - offset));
|
||||
|
||||
|
||||
} else if (strcmp_P((char *) t, (PGM_P) cmdlist[CMD_SHMWR]) == 0) {
|
||||
|
||||
@ -117,12 +117,14 @@ void sreg_set(uint32_t addr)
|
||||
void sram_bulk_addr_save()
|
||||
{
|
||||
addr_stash = addr_current;
|
||||
debug_P(DEBUG_SRAM, PSTR("sram_bulk_addr_save: addr=0x%08lx\n\r"), addr_stash);
|
||||
debug_P(DEBUG_SRAM, PSTR("sram_bulk_addr_save: addr=0x%08lx\n\r"),
|
||||
addr_stash);
|
||||
}
|
||||
|
||||
inline void sram_bulk_addr_restore()
|
||||
{
|
||||
debug_P(DEBUG_SRAM, PSTR("sram_bulk_addr_restore: addr=0x%08lx\n\r"), addr_stash);
|
||||
debug_P(DEBUG_SRAM, PSTR("sram_bulk_addr_restore: addr=0x%08lx\n\r"),
|
||||
addr_stash);
|
||||
sram_bulk_write_start(addr_stash);
|
||||
}
|
||||
|
||||
@ -215,7 +217,8 @@ uint8_t sram_read(uint32_t addr)
|
||||
|
||||
}
|
||||
|
||||
uint16_t sram_read16_be(uint32_t addr){
|
||||
uint16_t sram_read16_be(uint32_t addr)
|
||||
{
|
||||
uint8_t hi = sram_read(addr);
|
||||
uint8_t lo = sram_read(addr + 1);
|
||||
return (hi << 8 | lo);
|
||||
@ -260,7 +263,8 @@ void sram_bulk_write_end(void)
|
||||
|
||||
void sram_write(uint32_t addr, uint8_t data)
|
||||
{
|
||||
debug_P(DEBUG_SRAM_RAW, PSTR("sram_write: addr=0x%08lx data=%x\n\r"), addr, data);
|
||||
debug_P(DEBUG_SRAM_RAW, PSTR("sram_write: addr=0x%08lx data=%x\n\r"), addr,
|
||||
data);
|
||||
|
||||
avr_data_out();
|
||||
|
||||
@ -294,7 +298,9 @@ void sram_bulk_copy_from_buffer(uint32_t addr, uint8_t * src, uint32_t len)
|
||||
|
||||
uint32_t i;
|
||||
uint8_t *ptr = src;
|
||||
debug_P(DEBUG_SRAM, PSTR("sram_bulk_copy_from_buffer: addr=0x%08lx src=0x%p len=%li\n\r"),
|
||||
debug_P(DEBUG_SRAM,
|
||||
PSTR
|
||||
("sram_bulk_copy_from_buffer: addr=0x%08lx src=0x%p len=%li\n\r"),
|
||||
addr, src, len);
|
||||
sram_bulk_write_start(addr);
|
||||
for (i = addr; i < (addr + len); i++) {
|
||||
@ -312,7 +318,9 @@ void sram_bulk_copy_into_buffer(uint32_t addr, uint8_t * dst, uint32_t len)
|
||||
|
||||
uint32_t i;
|
||||
// uint8_t *ptr = dst;
|
||||
debug_P(DEBUG_SRAM, PSTR("sram_bulk_copy_into_buffer: addr=0x%08lx dst=0x%p len=%li\n\r"),
|
||||
debug_P(DEBUG_SRAM,
|
||||
PSTR
|
||||
("sram_bulk_copy_into_buffer: addr=0x%08lx dst=0x%p len=%li\n\r"),
|
||||
addr, dst, len);
|
||||
sram_bulk_read_start(addr);
|
||||
for (i = addr; i < (addr + len); i++) {
|
||||
@ -322,9 +330,11 @@ void sram_bulk_copy_into_buffer(uint32_t addr, uint8_t * dst, uint32_t len)
|
||||
sram_bulk_read_end();
|
||||
}
|
||||
|
||||
void sram_bulk_set(uint32_t addr, uint32_t len,uint8_t value){
|
||||
void sram_bulk_set(uint32_t addr, uint32_t len, uint8_t value)
|
||||
{
|
||||
uint32_t i;
|
||||
debug_P(DEBUG_SRAM, PSTR("sram_bulk_set: addr=0x%08lx len=%li\n\r"), addr,len);
|
||||
debug_P(DEBUG_SRAM, PSTR("sram_bulk_set: addr=0x%08lx len=%li\n\r"), addr,
|
||||
len);
|
||||
sram_bulk_write_start(addr);
|
||||
for (i = addr; i < (addr + len); i++) {
|
||||
if (0 == i % 0xfff)
|
||||
@ -334,4 +344,3 @@ void sram_bulk_set(uint32_t addr, uint32_t len,uint8_t value){
|
||||
}
|
||||
sram_bulk_write_end();
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,9 @@
|
||||
|
||||
|
||||
|
||||
/* ---------------------------- PORT A ---------------------------- */
|
||||
/*
|
||||
* ---------------------------- PORT A ----------------------------
|
||||
*/
|
||||
|
||||
#define AVR_DATA_PORT PORTA
|
||||
#define AVR_DATA_DIR DDRA
|
||||
@ -41,7 +43,9 @@
|
||||
#define avr_data_out() (AVR_DATA_DIR = 0xff)
|
||||
|
||||
|
||||
/* ---------------------------- PORT B ---------------------------- */
|
||||
/*
|
||||
* ---------------------------- PORT B ----------------------------
|
||||
*/
|
||||
|
||||
#define AVR_PORT PORTB
|
||||
#define AVR_DIR DDRB
|
||||
@ -78,7 +82,9 @@
|
||||
#define snes_irq_lo() (SNES_IRQ_PORT &= ~(1 << SNES_IRQ_PIN))
|
||||
|
||||
|
||||
/* ---------------------------- PORT C ---------------------------- */
|
||||
/*
|
||||
* ---------------------------- PORT C ----------------------------
|
||||
*/
|
||||
|
||||
#define AVR_ADDR_PORT PORTC
|
||||
#define AVR_ADDR_DIR DDRC
|
||||
@ -140,7 +146,9 @@
|
||||
#define led_pwm_on() (LED_DIR &=~ (1 << LED_PIN))
|
||||
#define led_pwm_off() (LED_DIR |= (1 << LED_PIN))
|
||||
|
||||
/* ---------------------------- PORT D ---------------------------- */
|
||||
/*
|
||||
* ---------------------------- PORT D ----------------------------
|
||||
*/
|
||||
|
||||
#define AVR_SNES_PORT PORTD
|
||||
#define AVR_SNES_DIR DDRD
|
||||
|
||||
@ -106,13 +106,15 @@ void system_set_bus_avr()
|
||||
system.bus_mode = MODE_AVR;
|
||||
}
|
||||
|
||||
void system_set_wr_disable(){
|
||||
void system_set_wr_disable()
|
||||
{
|
||||
snes_wr_disable();
|
||||
system.wr_line = WR_DISABLE;
|
||||
info_P(PSTR("Disable SNES WR\n"));
|
||||
}
|
||||
|
||||
void system_set_wr_enable(){
|
||||
void system_set_wr_enable()
|
||||
{
|
||||
snes_wr_enable();
|
||||
system.wr_line = WR_ENABLE;
|
||||
info_P(PSTR("Enable SNES WR\n"));
|
||||
@ -153,31 +155,36 @@ void system_set_rom_hirom()
|
||||
info_P(PSTR("Set SNES hirom \n"));
|
||||
}
|
||||
|
||||
char* system_status_helper(uint8_t val){
|
||||
char *system_status_helper(uint8_t val)
|
||||
{
|
||||
if (val)
|
||||
return "ON";
|
||||
else
|
||||
return "OFF";
|
||||
}
|
||||
|
||||
char* system_status_bus(uint8_t val){
|
||||
char *system_status_bus(uint8_t val)
|
||||
{
|
||||
if (val)
|
||||
return "SNES";
|
||||
else
|
||||
return "AVR";
|
||||
}
|
||||
|
||||
char* system_status_rom(uint8_t val){
|
||||
char *system_status_rom(uint8_t val)
|
||||
{
|
||||
if (val)
|
||||
return "HIROM";
|
||||
else
|
||||
return "LOROM";
|
||||
}
|
||||
|
||||
void system_status(){
|
||||
void system_status()
|
||||
{
|
||||
info_P(PSTR("\nBus Mode %s\n"), system_status_bus(system.bus_mode));
|
||||
info_P(PSTR("Rom Mode %s\n"), system_status_rom(system.rom_mode));
|
||||
info_P(PSTR("Reset Line %s\n"),system_status_helper(system.reset_line));
|
||||
info_P(PSTR("Reset Line %s\n"),
|
||||
system_status_helper(system.reset_line));
|
||||
info_P(PSTR("IRQ Line %s\n"), system_status_helper(system.irq_line));
|
||||
info_P(PSTR("WR Line %s\n"), system_status_helper(system.wr_line));
|
||||
info_P(PSTR("Reset IRQ %s\n"), system_status_helper(system.reset_irq));
|
||||
|
||||
@ -93,16 +93,20 @@ void test_non_zero_memory(uint32_t bottom_addr, uint32_t top_addr)
|
||||
}
|
||||
|
||||
|
||||
void test_memory_pattern(uint32_t bottom_addr, uint32_t top_addr, uint32_t bank_size)
|
||||
void test_memory_pattern(uint32_t bottom_addr, uint32_t top_addr,
|
||||
uint32_t bank_size)
|
||||
{
|
||||
uint32_t addr = 0;
|
||||
uint8_t pattern = 0x55;
|
||||
info_P(PSTR("test_memory_pattern: bottom_addr=0x%08lx top_addr=0x%08lx\n"), bottom_addr, top_addr);
|
||||
info_P(PSTR("test_memory_pattern: bottom_addr=0x%08lx top_addr=0x%08lx\n"),
|
||||
bottom_addr, top_addr);
|
||||
sram_bulk_write_start(bottom_addr);
|
||||
for (addr = bottom_addr; addr < top_addr; addr++) {
|
||||
if (addr % bank_size == 0) {
|
||||
pattern++;
|
||||
info_P(PSTR("test_memory_pattern: write addr=0x%08lx pattern=0x%08lx\n"), addr, pattern);
|
||||
info_P(PSTR
|
||||
("test_memory_pattern: write addr=0x%08lx pattern=0x%08lx\n"),
|
||||
addr, pattern);
|
||||
}
|
||||
sram_bulk_write(pattern);
|
||||
}
|
||||
@ -110,9 +114,12 @@ void test_memory_pattern(uint32_t bottom_addr, uint32_t top_addr, uint32_t bank_
|
||||
|
||||
|
||||
for (addr = bottom_addr; addr < top_addr; addr += bank_size) {
|
||||
info_P(PSTR("test_memory_pattern: dump bottom_addr=0x%08lx top_addr=0x%08lx\n"), addr, addr + bank_size);
|
||||
info_P(PSTR
|
||||
("test_memory_pattern: dump bottom_addr=0x%08lx top_addr=0x%08lx\n"),
|
||||
addr, addr + bank_size);
|
||||
dump_memory(addr, addr + bank_size);
|
||||
info_P(PSTR("----------------------------------------------------------------\n"));
|
||||
info_P(PSTR
|
||||
("----------------------------------------------------------------\n"));
|
||||
}
|
||||
|
||||
crc_check_bulk_memory((uint32_t) bottom_addr, top_addr, bank_size);
|
||||
@ -128,4 +135,3 @@ void test_crc()
|
||||
info_P(PSTR("test_crc: check\n"));
|
||||
test_non_zero_memory(0x000000, 0x10000);
|
||||
}
|
||||
|
||||
|
||||
@ -89,6 +89,3 @@ uint16_t timer_stop_int(void)
|
||||
uint16_t t = ((DEBOUNCE - prescaler) / DEBOUNCE) + second;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -45,23 +45,14 @@ FILE uart_stdout = FDEV_SETUP_STREAM(uart_stream, NULL, _FDEV_SETUP_WRITE);
|
||||
void uart_init(void)
|
||||
{
|
||||
UCSR0A = _BV(U2X0); /* improves baud rate error @ F_CPU = 1 MHz */
|
||||
UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(RXCIE0); /* tx/rx enable, rx complete
|
||||
* intr */
|
||||
UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(RXCIE0); /* tx/rx enable, rx complete * intr */
|
||||
UBRR0L = (F_CPU / (8 * 115200UL)) - 1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
ISR(USART0_RX_vect)
|
||||
{
|
||||
uint8_t c;
|
||||
c = UDR0;
|
||||
if (bit_is_clear(UCSR0A, FE0)) {
|
||||
rxbuff = c;
|
||||
intflags.rx_int = 1;
|
||||
}
|
||||
}
|
||||
* ISR(USART0_RX_vect) { uint8_t c; c = UDR0; if (bit_is_clear(UCSR0A, FE0)) { rxbuff = c; intflags.rx_int = 1; } }
|
||||
*/
|
||||
|
||||
void uart_putc(uint8_t c)
|
||||
|
||||
@ -34,6 +34,3 @@ void uart_puts(const char *s);
|
||||
void uart_puts_P(PGM_P s);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@ -27,8 +27,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "usbdrv.h"
|
||||
#include "oddebug.h" /* This is also an example for using debug
|
||||
* macros */
|
||||
#include "oddebug.h" /* This is also an example for using debug macros */
|
||||
#include "config.h"
|
||||
#include "requests.h" /* The custom request numbers we use */
|
||||
#include "uart.h"
|
||||
@ -48,14 +47,17 @@ uint8_t usbFunctionWrite(uint8_t * data, uint8_t len)
|
||||
uint8_t i;
|
||||
|
||||
if (len > usb_trans.rx_remaining) {
|
||||
info_P(PSTR("ERROR:usbFunctionWrite more data than expected remain: %i len: %i\n"),
|
||||
info_P(PSTR
|
||||
("ERROR:usbFunctionWrite more data than expected remain: %i len: %i\n"),
|
||||
usb_trans.rx_remaining, len);
|
||||
len = usb_trans.rx_remaining;
|
||||
}
|
||||
if (usb_trans.req_state == REQ_STATUS_BULK_UPLOAD) {
|
||||
|
||||
usb_trans.rx_remaining -= len;
|
||||
debug_P(DEBUG_USB_TRANS, PSTR("usbFunctionWrite REQ_STATUS_BULK_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n"),
|
||||
debug_P(DEBUG_USB_TRANS,
|
||||
PSTR
|
||||
("usbFunctionWrite REQ_STATUS_BULK_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n"),
|
||||
usb_trans.req_addr, len, usb_trans.rx_remaining);
|
||||
ptr = data;
|
||||
i = len;
|
||||
@ -73,7 +75,8 @@ uint8_t usbFunctionRead(uint8_t * data, uint8_t len)
|
||||
if (len > usb_trans.tx_remaining)
|
||||
len = usb_trans.tx_remaining;
|
||||
usb_trans.tx_remaining -= len;
|
||||
debug_P(DEBUG_USB_TRANS, PSTR("usbFunctionRead len=%i tx_remaining=%i \n"), len, usb_trans.tx_remaining);
|
||||
debug_P(DEBUG_USB_TRANS, PSTR("usbFunctionRead len=%i tx_remaining=%i \n"),
|
||||
len, usb_trans.tx_remaining);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
*data = usb_trans.tx_buffer[len];
|
||||
|
||||
@ -20,325 +20,287 @@
|
||||
|
||||
|
||||
|
||||
/* Name: usbconfig.h
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2005-04-01
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id: usbconfig-prototype.h 740 2009-04-13 18:23:31Z cs $
|
||||
/*
|
||||
* Name: usbconfig.h Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers Author: Christian Starkjohann Creation Date:
|
||||
* 2005-04-01 Tabsize: 4 Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH License: GNU GPL v2 (see License.txt), GNU GPL v3 or
|
||||
* proprietary (CommercialLicense.txt) This Revision: $Id: usbconfig-prototype.h 740 2009-04-13 18:23:31Z cs $
|
||||
*/
|
||||
|
||||
#ifndef __usbconfig_h_included__
|
||||
#define __usbconfig_h_included__
|
||||
|
||||
/*
|
||||
General Description:
|
||||
This file is an example configuration (with inline documentation) for the USB
|
||||
driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is
|
||||
also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may
|
||||
wire the lines to any other port, as long as D+ is also wired to INT0 (or any
|
||||
other hardware interrupt, as long as it is the highest level interrupt, see
|
||||
section at the end of this file).
|
||||
* General Description: This file is an example configuration (with inline documentation) for the USB driver. It configures V-USB for USB
|
||||
* D+ connected to Port D bit 2 (which is also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may wire the lines to
|
||||
* any other port, as long as D+ is also wired to INT0 (or any other hardware interrupt, as long as it is the highest level interrupt, see
|
||||
* section at the end of this file).
|
||||
*/
|
||||
|
||||
/* ---------------------------- Hardware Config ---------------------------- */
|
||||
/*
|
||||
* ---------------------------- Hardware Config ----------------------------
|
||||
*/
|
||||
|
||||
#define USB_CFG_IOPORTNAME D
|
||||
/* This is the port where the USB bus is connected. When you configure it to
|
||||
* "B", the registers PORTB, PINB and DDRB will be used.
|
||||
/*
|
||||
* This is the port where the USB bus is connected. When you configure it to "B", the registers PORTB, PINB and DDRB will be used.
|
||||
*/
|
||||
#define USB_CFG_DMINUS_BIT 4
|
||||
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
|
||||
* This may be any bit in the port.
|
||||
/*
|
||||
* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. This may be any bit in the port.
|
||||
*/
|
||||
#define USB_CFG_DPLUS_BIT 2
|
||||
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
|
||||
* This may be any bit in the port. Please note that D+ must also be connected
|
||||
* to interrupt pin INT0! [You can also use other interrupts, see section
|
||||
* "Optional MCU Description" below, or you can connect D- to the interrupt, as
|
||||
* it is required if you use the USB_COUNT_SOF feature. If you use D- for the
|
||||
* interrupt, the USB interrupt will also be triggered at Start-Of-Frame
|
||||
* markers every millisecond.]
|
||||
/*
|
||||
* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. This may be any bit in the port. Please note that D+ must
|
||||
* also be connected to interrupt pin INT0! [You can also use other interrupts, see section "Optional MCU Description" below, or you can
|
||||
* connect D- to the interrupt, as it is required if you use the USB_COUNT_SOF feature. If you use D- for the interrupt, the USB interrupt
|
||||
* will also be triggered at Start-Of-Frame markers every millisecond.]
|
||||
*/
|
||||
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
|
||||
/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
|
||||
* 16500 and 20000. The 12.8 MHz and 16.5 MHz versions of the code require no
|
||||
* crystal, they tolerate +/- 1% deviation from the nominal frequency. All
|
||||
* other rates require a precision of 2000 ppm and thus a crystal!
|
||||
* Default if not specified: 12 MHz
|
||||
/*
|
||||
* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000, 16500 and 20000. The 12.8 MHz and 16.5 MHz versions of the
|
||||
* code require no crystal, they tolerate +/- 1% deviation from the nominal frequency. All other rates require a precision of 2000 ppm and
|
||||
* thus a crystal! Default if not specified: 12 MHz
|
||||
*/
|
||||
#define USB_CFG_CHECK_CRC 0
|
||||
/* Define this to 1 if you want that the driver checks integrity of incoming
|
||||
* data packets (CRC checks). CRC checks cost quite a bit of code size and are
|
||||
* currently only available for 18 MHz crystal clock. You must choose
|
||||
* USB_CFG_CLOCK_KHZ = 18000 if you enable this option.
|
||||
/*
|
||||
* Define this to 1 if you want that the driver checks integrity of incoming data packets (CRC checks). CRC checks cost quite a bit of code
|
||||
* size and are currently only available for 18 MHz crystal clock. You must choose USB_CFG_CLOCK_KHZ = 18000 if you enable this option.
|
||||
*/
|
||||
|
||||
/* ----------------------- Optional Hardware Config ------------------------ */
|
||||
/*
|
||||
* ----------------------- Optional Hardware Config ------------------------
|
||||
*/
|
||||
|
||||
// #define USB_CFG_PULLUP_IOPORTNAME D
|
||||
/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
|
||||
* V+, you can connect and disconnect the device from firmware by calling
|
||||
* the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
|
||||
* This constant defines the port on which the pullup resistor is connected.
|
||||
/*
|
||||
* If you connect the 1.5k pullup resistor from D- to a port pin instead of V+, you can connect and disconnect the device from firmware by
|
||||
* calling the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h). This constant defines the port on which the pullup
|
||||
* resistor is connected.
|
||||
*/
|
||||
// #define USB_CFG_PULLUP_BIT 6
|
||||
/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
|
||||
* above) where the 1.5k pullup resistor is connected. See description
|
||||
* above for details.
|
||||
/*
|
||||
* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined above) where the 1.5k pullup resistor is connected. See
|
||||
* description above for details.
|
||||
*/
|
||||
|
||||
/* --------------------------- Functional Range ---------------------------- */
|
||||
/*
|
||||
* --------------------------- Functional Range ----------------------------
|
||||
*/
|
||||
|
||||
#define USB_CFG_HAVE_INTRIN_ENDPOINT 0
|
||||
/* Define this to 1 if you want to compile a version with two endpoints: The
|
||||
* default control endpoint 0 and an interrupt-in endpoint (any other endpoint
|
||||
* number).
|
||||
/*
|
||||
* Define this to 1 if you want to compile a version with two endpoints: The default control endpoint 0 and an interrupt-in endpoint (any
|
||||
* other endpoint number).
|
||||
*/
|
||||
#define USB_CFG_HAVE_INTRIN_ENDPOINT3 0
|
||||
/* Define this to 1 if you want to compile a version with three endpoints: The
|
||||
* default control endpoint 0, an interrupt-in endpoint 3 (or the number
|
||||
* configured below) and a catch-all default interrupt-in endpoint as above.
|
||||
* You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.
|
||||
/*
|
||||
* Define this to 1 if you want to compile a version with three endpoints: The default control endpoint 0, an interrupt-in endpoint 3 (or
|
||||
* the number configured below) and a catch-all default interrupt-in endpoint as above. You must also define USB_CFG_HAVE_INTRIN_ENDPOINT
|
||||
* to 1 for this feature.
|
||||
*/
|
||||
#define USB_CFG_EP3_NUMBER 3
|
||||
/* If the so-called endpoint 3 is used, it can now be configured to any other
|
||||
* endpoint number (except 0) with this macro. Default if undefined is 3.
|
||||
/*
|
||||
* If the so-called endpoint 3 is used, it can now be configured to any other endpoint number (except 0) with this macro. Default if
|
||||
* undefined is 3.
|
||||
*/
|
||||
/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */
|
||||
/* The above macro defines the startup condition for data toggling on the
|
||||
* interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1.
|
||||
* Since the token is toggled BEFORE sending any data, the first packet is
|
||||
* sent with the oposite value of this configuration!
|
||||
/*
|
||||
* #define USB_INITIAL_DATATOKEN USBPID_DATA1
|
||||
*/
|
||||
/*
|
||||
* The above macro defines the startup condition for data toggling on the interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1. Since
|
||||
* the token is toggled BEFORE sending any data, the first packet is sent with the oposite value of this configuration!
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_HALT 0
|
||||
/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature
|
||||
* for endpoint 1 (interrupt endpoint). Although you may not need this feature,
|
||||
* it is required by the standard. We have made it a config option because it
|
||||
* bloats the code considerably.
|
||||
/*
|
||||
* Define this to 1 if you also want to implement the ENDPOINT_HALT feature for endpoint 1 (interrupt endpoint). Although you may not need
|
||||
* this feature, it is required by the standard. We have made it a config option because it bloats the code considerably.
|
||||
*/
|
||||
#define USB_CFG_SUPPRESS_INTR_CODE 1
|
||||
/* Define this to 1 if you want to declare interrupt-in endpoints, but don't
|
||||
* want to send any data over them. If this macro is defined to 1, functions
|
||||
* usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if
|
||||
* you need the interrupt-in endpoints in order to comply to an interface
|
||||
* (e.g. HID), but never want to send any data. This option saves a couple
|
||||
* of bytes in flash memory and the transmit buffers in RAM.
|
||||
/*
|
||||
* Define this to 1 if you want to declare interrupt-in endpoints, but don't want to send any data over them. If this macro is defined to
|
||||
* 1, functions usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if you need the interrupt-in endpoints in order to
|
||||
* comply to an interface (e.g. HID), but never want to send any data. This option saves a couple of bytes in flash memory and the transmit
|
||||
* buffers in RAM.
|
||||
*/
|
||||
#define USB_CFG_INTR_POLL_INTERVAL 20
|
||||
/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
|
||||
* interval. The value is in milliseconds and must not be less than 10 ms for
|
||||
* low speed devices.
|
||||
/*
|
||||
* If you compile a version with endpoint 1 (interrupt-in), this is the poll interval. The value is in milliseconds and must not be less
|
||||
* than 10 ms for low speed devices.
|
||||
*/
|
||||
#define USB_CFG_IS_SELF_POWERED 0
|
||||
/* Define this to 1 if the device has its own power supply. Set it to 0 if the
|
||||
* device is powered from the USB bus.
|
||||
/*
|
||||
* Define this to 1 if the device has its own power supply. Set it to 0 if the device is powered from the USB bus.
|
||||
*/
|
||||
#define USB_CFG_MAX_BUS_POWER 300
|
||||
/* Set this variable to the maximum USB bus power consumption of your device.
|
||||
* The value is in milliamperes. [It will be divided by two since USB
|
||||
* communicates power requirements in units of 2 mA.]
|
||||
/*
|
||||
* Set this variable to the maximum USB bus power consumption of your device. The value is in milliamperes. [It will be divided by two
|
||||
* since USB communicates power requirements in units of 2 mA.]
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_WRITE 1
|
||||
/* Set this to 1 if you want usbFunctionWrite() to be called for control-out
|
||||
* transfers. Set it to 0 if you don't need it and want to save a couple of
|
||||
* bytes.
|
||||
/*
|
||||
* Set this to 1 if you want usbFunctionWrite() to be called for control-out transfers. Set it to 0 if you don't need it and want to save a
|
||||
* couple of bytes.
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_READ 0
|
||||
/* Set this to 1 if you need to send control replies which are generated
|
||||
* "on the fly" when usbFunctionRead() is called. If you only want to send
|
||||
* data from a static buffer, set it to 0 and return the data from
|
||||
* usbFunctionSetup(). This saves a couple of bytes.
|
||||
/*
|
||||
* Set this to 1 if you need to send control replies which are generated "on the fly" when usbFunctionRead() is called. If you only want to
|
||||
* send data from a static buffer, set it to 0 and return the data from usbFunctionSetup(). This saves a couple of bytes.
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0
|
||||
/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints.
|
||||
* You must implement the function usbFunctionWriteOut() which receives all
|
||||
* interrupt/bulk data sent to any endpoint other than 0. The endpoint number
|
||||
* can be found in 'usbRxToken'.
|
||||
/*
|
||||
* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints. You must implement the function usbFunctionWriteOut() which
|
||||
* receives all interrupt/bulk data sent to any endpoint other than 0. The endpoint number can be found in 'usbRxToken'.
|
||||
*/
|
||||
#define USB_CFG_HAVE_FLOWCONTROL 0
|
||||
/* Define this to 1 if you want flowcontrol over USB data. See the definition
|
||||
* of the macros usbDisableAllRequests() and usbEnableAllRequests() in
|
||||
* usbdrv.h.
|
||||
/*
|
||||
* Define this to 1 if you want flowcontrol over USB data. See the definition of the macros usbDisableAllRequests() and
|
||||
* usbEnableAllRequests() in usbdrv.h.
|
||||
*/
|
||||
#define USB_CFG_LONG_TRANSFERS 0
|
||||
/* Define this to 1 if you want to send/receive blocks of more than 254 bytes
|
||||
* in a single control-in or control-out transfer. Note that the capability
|
||||
* for long transfers increases the driver size.
|
||||
/*
|
||||
* Define this to 1 if you want to send/receive blocks of more than 254 bytes in a single control-in or control-out transfer. Note that the
|
||||
* capability for long transfers increases the driver size.
|
||||
*/
|
||||
/* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */
|
||||
/* This macro is a hook if you want to do unconventional things. If it is
|
||||
* defined, it's inserted at the beginning of received message processing.
|
||||
* If you eat the received message and don't want default processing to
|
||||
* proceed, do a return after doing your things. One possible application
|
||||
* (besides debugging) is to flash a status LED on each packet.
|
||||
/*
|
||||
* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED();
|
||||
*/
|
||||
/* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */
|
||||
/* This macro is a hook if you need to know when an USB RESET occurs. It has
|
||||
* one parameter which distinguishes between the start of RESET state and its
|
||||
* end.
|
||||
/*
|
||||
* This macro is a hook if you want to do unconventional things. If it is defined, it's inserted at the beginning of received message
|
||||
* processing. If you eat the received message and don't want default processing to proceed, do a return after doing your things. One
|
||||
* possible application (besides debugging) is to flash a status LED on each packet.
|
||||
*/
|
||||
/* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */
|
||||
/* This macro (if defined) is executed when a USB SET_ADDRESS request was
|
||||
* received.
|
||||
/*
|
||||
* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();}
|
||||
*/
|
||||
/*
|
||||
* This macro is a hook if you need to know when an USB RESET occurs. It has one parameter which distinguishes between the start of RESET
|
||||
* state and its end.
|
||||
*/
|
||||
/*
|
||||
* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned();
|
||||
*/
|
||||
/*
|
||||
* This macro (if defined) is executed when a USB SET_ADDRESS request was received.
|
||||
*/
|
||||
#define USB_COUNT_SOF 0
|
||||
/* define this macro to 1 if you need the global variable "usbSofCount" which
|
||||
* counts SOF packets. This feature requires that the hardware interrupt is
|
||||
* connected to D- instead of D+.
|
||||
/*
|
||||
* define this macro to 1 if you need the global variable "usbSofCount" which counts SOF packets. This feature requires that the hardware
|
||||
* interrupt is connected to D- instead of D+.
|
||||
*/
|
||||
/* #ifdef __ASSEMBLER__
|
||||
* macro myAssemblerMacro
|
||||
* in YL, TCNT0
|
||||
* sts timer0Snapshot, YL
|
||||
* endm
|
||||
* #endif
|
||||
* #define USB_SOF_HOOK myAssemblerMacro
|
||||
* This macro (if defined) is executed in the assembler module when a
|
||||
* Start Of Frame condition is detected. It is recommended to define it to
|
||||
* the name of an assembler macro which is defined here as well so that more
|
||||
* than one assembler instruction can be used. The macro may use the register
|
||||
* YL and modify SREG. If it lasts longer than a couple of cycles, USB messages
|
||||
* immediately after an SOF pulse may be lost and must be retried by the host.
|
||||
* What can you do with this hook? Since the SOF signal occurs exactly every
|
||||
* 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in
|
||||
* designs running on the internal RC oscillator.
|
||||
* Please note that Start Of Frame detection works only if D- is wired to the
|
||||
* interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!
|
||||
/*
|
||||
* #ifdef __ASSEMBLER__ macro myAssemblerMacro in YL, TCNT0 sts timer0Snapshot, YL endm #endif #define USB_SOF_HOOK myAssemblerMacro This
|
||||
* macro (if defined) is executed in the assembler module when a Start Of Frame condition is detected. It is recommended to define it to
|
||||
* the name of an assembler macro which is defined here as well so that more than one assembler instruction can be used. The macro may use
|
||||
* the register YL and modify SREG. If it lasts longer than a couple of cycles, USB messages immediately after an SOF pulse may be lost and
|
||||
* must be retried by the host. What can you do with this hook? Since the SOF signal occurs exactly every 1 ms (unless the host is in sleep
|
||||
* mode), you can use it to tune OSCCAL in designs running on the internal RC oscillator. Please note that Start Of Frame detection works
|
||||
* only if D- is wired to the interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!
|
||||
*/
|
||||
#define USB_CFG_CHECK_DATA_TOGGLING 0
|
||||
/* define this macro to 1 if you want to filter out duplicate data packets
|
||||
* sent by the host. Duplicates occur only as a consequence of communication
|
||||
* errors, when the host does not receive an ACK. Please note that you need to
|
||||
* implement the filtering yourself in usbFunctionWriteOut() and
|
||||
* usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable
|
||||
* for each control- and out-endpoint to check for duplicate packets.
|
||||
/*
|
||||
* define this macro to 1 if you want to filter out duplicate data packets sent by the host. Duplicates occur only as a consequence of
|
||||
* communication errors, when the host does not receive an ACK. Please note that you need to implement the filtering yourself in
|
||||
* usbFunctionWriteOut() and usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable for each control- and
|
||||
* out-endpoint to check for duplicate packets.
|
||||
*/
|
||||
#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0
|
||||
/* define this macro to 1 if you want the function usbMeasureFrameLength()
|
||||
* compiled in. This function can be used to calibrate the AVR's RC oscillator.
|
||||
/*
|
||||
* define this macro to 1 if you want the function usbMeasureFrameLength() compiled in. This function can be used to calibrate the AVR's RC
|
||||
* oscillator.
|
||||
*/
|
||||
|
||||
/* -------------------------- Device Description --------------------------- */
|
||||
/*
|
||||
* -------------------------- Device Description ---------------------------
|
||||
*/
|
||||
|
||||
#define USB_CFG_VENDOR_ID 0xc0, 0x16
|
||||
/* USB vendor ID for the device, low byte first. If you have registered your
|
||||
* own Vendor ID, define it here. Otherwise you use one of obdev's free shared
|
||||
* VID/PID pairs. Be sure to read USBID-License.txt for rules!
|
||||
/*
|
||||
* USB vendor ID for the device, low byte first. If you have registered your own Vendor ID, define it here. Otherwise you use one of
|
||||
* obdev's free shared VID/PID pairs. Be sure to read USBID-License.txt for rules!
|
||||
*/
|
||||
#define USB_CFG_DEVICE_ID 0xdd, 0x05
|
||||
/* This is the ID of the product, low byte first. It is interpreted in the
|
||||
* scope of the vendor ID. If you have registered your own VID with usb.org
|
||||
* or if you have licensed a PID from somebody else, define it here. Otherwise
|
||||
* you use obdev's free shared VID/PID pair. Be sure to read the rules in
|
||||
* USBID-License.txt!
|
||||
/*
|
||||
* This is the ID of the product, low byte first. It is interpreted in the scope of the vendor ID. If you have registered your own VID with
|
||||
* usb.org or if you have licensed a PID from somebody else, define it here. Otherwise you use obdev's free shared VID/PID pair. Be sure to
|
||||
* read the rules in USBID-License.txt!
|
||||
*/
|
||||
#define USB_CFG_DEVICE_VERSION 0x00, 0x01
|
||||
/* Version number of the device: Minor number first, then major number.
|
||||
/*
|
||||
* Version number of the device: Minor number first, then major number.
|
||||
*/
|
||||
#define USB_CFG_VENDOR_NAME 'o', 'p', 't', 'i', 'x', 'x', '.', 'o', 'r', 'g'
|
||||
#define USB_CFG_VENDOR_NAME_LEN 10
|
||||
/* These two values define the vendor name returned by the USB device. The name
|
||||
* must be given as a list of characters under single quotes. The characters
|
||||
* are interpreted as Unicode (UTF-16) entities.
|
||||
* If you don't want a vendor name string, undefine these macros.
|
||||
* ALWAYS define a vendor name containing your Internet domain name if you use
|
||||
* obdev's free shared VID/PID pair. See the file USBID-License.txt for
|
||||
* details.
|
||||
/*
|
||||
* These two values define the vendor name returned by the USB device. The name must be given as a list of characters under single quotes.
|
||||
* The characters are interpreted as Unicode (UTF-16) entities. If you don't want a vendor name string, undefine these macros. ALWAYS
|
||||
* define a vendor name containing your Internet domain name if you use obdev's free shared VID/PID pair. See the file USBID-License.txt
|
||||
* for details.
|
||||
*/
|
||||
#define USB_CFG_DEVICE_NAME 'Q', 'U', 'I', 'C', 'K', 'D', 'E', 'V', '1', '6'
|
||||
#define USB_CFG_DEVICE_NAME_LEN 10
|
||||
/* Same as above for the device name. If you don't want a device name, undefine
|
||||
* the macros. See the file USBID-License.txt before you assign a name if you
|
||||
* use a shared VID/PID.
|
||||
/*
|
||||
* Same as above for the device name. If you don't want a device name, undefine the macros. See the file USBID-License.txt before you
|
||||
* assign a name if you use a shared VID/PID.
|
||||
*/
|
||||
/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
|
||||
/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
|
||||
/* Same as above for the serial number. If you don't want a serial number,
|
||||
* undefine the macros.
|
||||
* It may be useful to provide the serial number through other means than at
|
||||
* compile time. See the section about descriptor properties below for how
|
||||
* to fine tune control over USB descriptors such as the string descriptor
|
||||
* for the serial number.
|
||||
/*
|
||||
* #define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e'
|
||||
*/
|
||||
/*
|
||||
* #define USB_CFG_SERIAL_NUMBER_LEN 0
|
||||
*/
|
||||
/*
|
||||
* Same as above for the serial number. If you don't want a serial number, undefine the macros. It may be useful to provide the serial
|
||||
* number through other means than at compile time. See the section about descriptor properties below for how to fine tune control over USB
|
||||
* descriptors such as the string descriptor for the serial number.
|
||||
*/
|
||||
#define USB_CFG_DEVICE_CLASS 0xff /* set to 0 if deferred to interface */
|
||||
#define USB_CFG_DEVICE_SUBCLASS 0
|
||||
/* See USB specification if you want to conform to an existing device class.
|
||||
* Class 0xff is "vendor specific".
|
||||
/*
|
||||
* See USB specification if you want to conform to an existing device class. Class 0xff is "vendor specific".
|
||||
*/
|
||||
#define USB_CFG_INTERFACE_CLASS 0 /* define class here if not at device level */
|
||||
#define USB_CFG_INTERFACE_SUBCLASS 0
|
||||
#define USB_CFG_INTERFACE_PROTOCOL 0
|
||||
/* See USB specification if you want to conform to an existing device class or
|
||||
* protocol. The following classes must be set at interface level:
|
||||
* HID class is 3, no subclass and protocol required (but may be useful!)
|
||||
* CDC class is 2, use subclass 2 and protocol 1 for ACM
|
||||
/*
|
||||
* See USB specification if you want to conform to an existing device class or protocol. The following classes must be set at interface
|
||||
* level: HID class is 3, no subclass and protocol required (but may be useful!) CDC class is 2, use subclass 2 and protocol 1 for ACM
|
||||
*/
|
||||
#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0
|
||||
|
||||
/* Define this to the length of the HID report descriptor, if you implement
|
||||
* an HID device. Otherwise don't define it or define it to 0.
|
||||
* If you use this define, you must add a PROGMEM character array named
|
||||
* "usbHidReportDescriptor" to your code which contains the report descriptor.
|
||||
* Don't forget to keep the array and this define in sync!
|
||||
/*
|
||||
* Define this to the length of the HID report descriptor, if you implement an HID device. Otherwise don't define it or define it to 0. If
|
||||
* you use this define, you must add a PROGMEM character array named "usbHidReportDescriptor" to your code which contains the report
|
||||
* descriptor. Don't forget to keep the array and this define in sync!
|
||||
*/
|
||||
|
||||
/* #define USB_PUBLIC static */
|
||||
/* Use the define above if you #include usbdrv.c instead of linking against it.
|
||||
* This technique saves a couple of bytes in flash memory.
|
||||
/*
|
||||
* #define USB_PUBLIC static
|
||||
*/
|
||||
/*
|
||||
* Use the define above if you #include usbdrv.c instead of linking against it. This technique saves a couple of bytes in flash memory.
|
||||
*/
|
||||
|
||||
/* ------------------- Fine Control over USB Descriptors ------------------- */
|
||||
/* If you don't want to use the driver's default USB descriptors, you can
|
||||
* provide our own. These can be provided as (1) fixed length static data in
|
||||
* flash memory, (2) fixed length static data in RAM or (3) dynamically at
|
||||
* runtime in the function usbFunctionDescriptor(). See usbdrv.h for more
|
||||
* information about this function.
|
||||
* Descriptor handling is configured through the descriptor's properties. If
|
||||
* no properties are defined or if they are 0, the default descriptor is used.
|
||||
* Possible properties are:
|
||||
* + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched
|
||||
* at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is
|
||||
* used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if
|
||||
* you want RAM pointers.
|
||||
* + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found
|
||||
* in static memory is in RAM, not in flash memory.
|
||||
* + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash),
|
||||
* the driver must know the descriptor's length. The descriptor itself is
|
||||
* found at the address of a well known identifier (see below).
|
||||
* List of static descriptor names (must be declared PROGMEM if in flash):
|
||||
* char usbDescriptorDevice[];
|
||||
* char usbDescriptorConfiguration[];
|
||||
* char usbDescriptorHidReport[];
|
||||
* char usbDescriptorString0[];
|
||||
* int usbDescriptorStringVendor[];
|
||||
* int usbDescriptorStringDevice[];
|
||||
* int usbDescriptorStringSerialNumber[];
|
||||
* Other descriptors can't be provided statically, they must be provided
|
||||
* dynamically at runtime.
|
||||
*
|
||||
* Descriptor properties are or-ed or added together, e.g.:
|
||||
* #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18))
|
||||
*
|
||||
* The following descriptors are defined:
|
||||
* USB_CFG_DESCR_PROPS_DEVICE
|
||||
* USB_CFG_DESCR_PROPS_CONFIGURATION
|
||||
* USB_CFG_DESCR_PROPS_STRINGS
|
||||
* USB_CFG_DESCR_PROPS_STRING_0
|
||||
* USB_CFG_DESCR_PROPS_STRING_VENDOR
|
||||
* USB_CFG_DESCR_PROPS_STRING_PRODUCT
|
||||
* USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
|
||||
* USB_CFG_DESCR_PROPS_HID
|
||||
* USB_CFG_DESCR_PROPS_HID_REPORT
|
||||
* USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver)
|
||||
*
|
||||
* Note about string descriptors: String descriptors are not just strings, they
|
||||
* are Unicode strings prefixed with a 2 byte header. Example:
|
||||
* int serialNumberDescriptor[] = {
|
||||
* USB_STRING_DESCRIPTOR_HEADER(6),
|
||||
* 'S', 'e', 'r', 'i', 'a', 'l'
|
||||
/*
|
||||
* ------------------- Fine Control over USB Descriptors -------------------
|
||||
*/
|
||||
/*
|
||||
* If you don't want to use the driver's default USB descriptors, you can provide our own. These can be provided as (1) fixed length static
|
||||
* data in flash memory, (2) fixed length static data in RAM or (3) dynamically at runtime in the function usbFunctionDescriptor(). See
|
||||
* usbdrv.h for more information about this function. Descriptor handling is configured through the descriptor's properties. If no
|
||||
* properties are defined or if they are 0, the default descriptor is used. Possible properties are: + USB_PROP_IS_DYNAMIC: The data for
|
||||
* the descriptor should be fetched at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is used, the data is in FLASH by
|
||||
* default. Add property USB_PROP_IS_RAM if you want RAM pointers. + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or
|
||||
* found in static memory is in RAM, not in flash memory. + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash), the
|
||||
* driver must know the descriptor's length. The descriptor itself is found at the address of a well known identifier (see below). List of
|
||||
* static descriptor names (must be declared PROGMEM if in flash): char usbDescriptorDevice[]; char usbDescriptorConfiguration[]; char
|
||||
* usbDescriptorHidReport[]; char usbDescriptorString0[]; int usbDescriptorStringVendor[]; int usbDescriptorStringDevice[]; int
|
||||
* usbDescriptorStringSerialNumber[]; Other descriptors can't be provided statically, they must be provided dynamically at runtime.
|
||||
* Descriptor properties are or-ed or added together, e.g.: #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18)) The
|
||||
* following descriptors are defined: USB_CFG_DESCR_PROPS_DEVICE USB_CFG_DESCR_PROPS_CONFIGURATION USB_CFG_DESCR_PROPS_STRINGS
|
||||
* USB_CFG_DESCR_PROPS_STRING_0 USB_CFG_DESCR_PROPS_STRING_VENDOR USB_CFG_DESCR_PROPS_STRING_PRODUCT
|
||||
* USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER USB_CFG_DESCR_PROPS_HID USB_CFG_DESCR_PROPS_HID_REPORT USB_CFG_DESCR_PROPS_UNKNOWN (for all
|
||||
* descriptors not handled by the driver) Note about string descriptors: String descriptors are not just strings, they are Unicode strings
|
||||
* prefixed with a 2 byte header. Example: int serialNumberDescriptor[] = { USB_STRING_DESCRIPTOR_HEADER(6), 'S', 'e', 'r', 'i', 'a', 'l'
|
||||
* };
|
||||
*/
|
||||
|
||||
@ -353,21 +315,38 @@ section at the end of this file).
|
||||
#define USB_CFG_DESCR_PROPS_HID_REPORT 0
|
||||
#define USB_CFG_DESCR_PROPS_UNKNOWN 0
|
||||
|
||||
/* ----------------------- Optional MCU Description ------------------------ */
|
||||
|
||||
/* The following configurations have working defaults in usbdrv.h. You
|
||||
* usually don't need to set them explicitly. Only if you want to run
|
||||
* the driver on a device which is not yet supported or with a compiler
|
||||
* which is not fully supported (such as IAR C) or if you use a differnt
|
||||
* interrupt than INT0, you may have to define some of these.
|
||||
/*
|
||||
* ----------------------- Optional MCU Description ------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following configurations have working defaults in usbdrv.h. You usually don't need to set them explicitly. Only if you want to run
|
||||
* the driver on a device which is not yet supported or with a compiler which is not fully supported (such as IAR C) or if you use a
|
||||
* differnt interrupt than INT0, you may have to define some of these.
|
||||
*/
|
||||
/*
|
||||
* #define USB_INTR_CFG MCUCR
|
||||
*/
|
||||
/*
|
||||
* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01))
|
||||
*/
|
||||
/*
|
||||
* #define USB_INTR_CFG_CLR 0
|
||||
*/
|
||||
/*
|
||||
* #define USB_INTR_ENABLE GIMSK
|
||||
*/
|
||||
/*
|
||||
* #define USB_INTR_ENABLE_BIT INT0
|
||||
*/
|
||||
/*
|
||||
* #define USB_INTR_PENDING GIFR
|
||||
*/
|
||||
/*
|
||||
* #define USB_INTR_PENDING_BIT INTF0
|
||||
*/
|
||||
/*
|
||||
* #define USB_INTR_VECTOR SIG_INTERRUPT0
|
||||
*/
|
||||
/* #define USB_INTR_CFG MCUCR */
|
||||
/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */
|
||||
/* #define USB_INTR_CFG_CLR 0 */
|
||||
/* #define USB_INTR_ENABLE GIMSK */
|
||||
/* #define USB_INTR_ENABLE_BIT INT0 */
|
||||
/* #define USB_INTR_PENDING GIFR */
|
||||
/* #define USB_INTR_PENDING_BIT INTF0 */
|
||||
/* #define USB_INTR_VECTOR SIG_INTERRUPT0 */
|
||||
|
||||
#endif /* __usbconfig_h_included__ */
|
||||
|
||||
@ -55,30 +55,45 @@ void util_trim(uint8_t *s)
|
||||
{
|
||||
uint8_t *p = s;
|
||||
uint8_t *q;
|
||||
/* skip leading whitespace */
|
||||
/*
|
||||
* skip leading whitespace
|
||||
*/
|
||||
while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')
|
||||
p++;
|
||||
/* now p points at the first non-whitespace uint8_tacter */
|
||||
/*
|
||||
* now p points at the first non-whitespace uint8_tacter
|
||||
*/
|
||||
|
||||
if (*p == '\0') {
|
||||
/* only whitespace */
|
||||
/*
|
||||
* only whitespace
|
||||
*/
|
||||
*s = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
q = s + strlen((char *) s);
|
||||
/* skip trailing whitespace */
|
||||
/* we have found p < q such that *p is non-whitespace,
|
||||
so this loop terminates with q >= p */
|
||||
/*
|
||||
* skip trailing whitespace
|
||||
*/
|
||||
/*
|
||||
* we have found p < q such that *p is non-whitespace, so this loop terminates with q >= p
|
||||
*/
|
||||
do
|
||||
q--;
|
||||
while (*q == ' ' || *q == '\t' || *q == '\r' || *q == '\n');
|
||||
|
||||
/* now q points at the last non-whitespace uint8_tacter */
|
||||
/* cut off trailing whitespace */
|
||||
/*
|
||||
* now q points at the last non-whitespace uint8_tacter
|
||||
*/
|
||||
/*
|
||||
* cut off trailing whitespace
|
||||
*/
|
||||
*++q = '\0';
|
||||
|
||||
/* move to string */
|
||||
/*
|
||||
* move to string
|
||||
*/
|
||||
memmove(s, p, q + 1 - p);
|
||||
}
|
||||
|
||||
@ -128,5 +143,3 @@ uint8_t util_sscanbool(const uint8_t *s)
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -28,4 +28,3 @@ void wdt_init(void)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -39,4 +39,3 @@ do \
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user