aboutsummaryrefslogtreecommitdiff
path: root/bootloaders/nuevo_diskloader/src/Platform.h
blob: e3006904c8ffb1c784b0ce86fae73f1a36d3140b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 *  Platform.h
 */

#ifndef __PLATFORM_H__
#define __PLATFORM_H__

#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/boot.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef __cplusplus
extern "C"{
#endif

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;

#define CDC_ENABLED

//#include "USBDesc.h"
//#include "../../../cores/arduino/USBCore.h"
#include "USBAPI.h"

#define CPU_PRESCALE(n)	(CLKPR = 0x80, CLKPR = (n))
#define DISABLE_JTAG()  MCUCR = (1 << JTD) | (1 << IVCE) | (0 << PUD); MCUCR = (1 << JTD) | (0 << IVSEL) | (0 << IVCE) | (0 << PUD)

#define BOARD_INIT()	DDRC |= (1<<7); DDRB |= (1<<0); DDRE |= (1<<6); CPU_PRESCALE(0); DISABLE_JTAG();	// for XXX-series boards
//#define BOARD_INIT()	DDRC |= (1<<7); DDRB |= (1<<0); DDRD |= (1<<5); CPU_PRESCALE(0); DISABLE_JTAG();	// for non-XXX boards

// for XXX-series boards
#define TX_LED_OFF()		PORTE |= (1<<6)
#define TX_LED_ON()			PORTE &= ~(1<<6)
#define RX_LED_OFF()		PORTB |= (1<<0)
#define RX_LED_ON()			PORTB &= ~(1<<0)
#define L_LED_OFF()			PORTC &= ~(1<<7)
#define L_LED_ON()			PORTC |= (1<<7)

// these for non-XXX boards
//#define LED0			PORTC &= ~(1<<7)
//#define LED1			PORTC |= (1<<7)
//#define TXLED0			PORTD |= (1<<5)
//#define TXLED1			PORTD &= ~(1<<5)
//#define RXLED0			PORTB |= (1<<0)
//#define RXLED1			PORTB &= ~(1<<0)

#ifdef __cplusplus
}	/* extern "C"{ */
#endif 

#endif /* __PLATFORM_H__ */