Progamando o Lab_uino como Arduino


Tabela de pinagem​

Preparando o software Arduino


A Placa Lab_uino pode ser programada como uma placa "Arduino Leonardo" ou como Lab_Uino com a inclusão dos dados no software do Arduino.


Para incluir a placa no software do Arduino siga os passos abaixo ou execute o download dos arquivos ​clicando aqui


1) Altere o Arquivo boards.txt (..\hardware\arduino) e inclua as definições para a placa Lab_uino conforme abaixo


Lab_Uino.name=Lab_Uino

Lab_Uino.upload.protocol=avr109

Lab_Uino.upload.maximum_size=28672

Lab_Uino.upload.speed=57600

Lab_Uino.upload.disable_flushing=true

Lab_Uino.bootloader.low_fuses=0xff

Lab_Uino.bootloader.high_fuses=0xd8

Lab_Uino.bootloader.extended_fuses=0xcb

Lab_Uino.bootloader.path=caterina

Lab_Uino.bootloader.file=Caterina-Leonardo.hex

Lab_Uino.bootloader.unlock_bits=0x3F

Lab_Uino.bootloader.lock_bits=0x2F

Lab_Uino.build.mcu=atmega32u4

Lab_Uino.build.f_cpu=8000000L

Lab_Uino.build.vid=0x2341

Lab_Uino.build.pid=0x8036

Lab_Uino.build.core=arduino

Lab_Uino.build.variant=Lab_Uino


2) Inclua no diretório ..\hardware\arduino\variants uma nova pasta com nome Lab_uino e crie o arquivo  pins_arduino.h com os dados:


/*

pins_arduino.h - Pin definition functions for Arduino

Part of Arduino - http://www.arduino.cc/

Copyright (c) 2007 David A. Mellis

This library is free software; you can redistribute it and/or

modify it under the terms of the GNU Lesser General Public

License as published by the Free Software Foundation; either

version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General

Public License along with this library; if not, write to the

Free Software Foundation, Inc., 59 Temple Place, Suite 330,

Boston, MA 02111-1307 USA

$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $

*/

#ifndef Pins_Arduino_h

#define Pins_Arduino_h

#include <avr/pgmspace.h>

// Workaround for wrong definitions in "iom32u4.h".

// This should be fixed in the AVR toolchain.

#undef UHCON

#undef UHINT

#undef UHIEN

#undef UHADDR

#undef UHFNUM

#undef UHFNUML

#undef UHFNUMH

#undef UHFLEN

#undef UPINRQX

#undef UPINTX

#undef UPNUM

#undef UPRST

#undef UPCONX

#undef UPCFG0X

#undef UPCFG1X

#undef UPSTAX

#undef UPCFG2X

#undef UPIENX

#undef UPDATX

#undef TCCR2A

#undef WGM20

#undef WGM21

#undef COM2B0

#undef COM2B1

#undef COM2A0

#undef COM2A1

#undef TCCR2B

#undef CS20

#undef CS21

#undef CS22

#undef WGM22

#undef FOC2B

#undef FOC2A

#undef TCNT2

#undef TCNT2_0

#undef TCNT2_1

#undef TCNT2_2

#undef TCNT2_3

#undef TCNT2_4

#undef TCNT2_5

#undef TCNT2_6

#undef TCNT2_7

#undef OCR2A

#undef OCR2_0

#undef OCR2_1

#undef OCR2_2

#undef OCR2_3

#undef OCR2_4

#undef OCR2_5

#undef OCR2_6

#undef OCR2_7

#undef OCR2B

#undef OCR2_0

#undef OCR2_1

#undef OCR2_2

#undef OCR2_3

#undef OCR2_4

#undef OCR2_5

#undef OCR2_6

#undef OCR2_7

#define NUM_DIGITAL_PINS 26

#define NUM_ANALOG_INPUTS 4

#define TX_RX_LED_INIT

#define TXLED0

#define TXLED1

#define RXLED0

#define RXLED1

static const uint8_t SDA = 15;

static const uint8_t SCL = 14;

// Map SPI port

static const uint8_t SS = 0;

static const uint8_t MOSI = 4;

static const uint8_t MISO = 2;

static const uint8_t SCK = 3;

// Mapping of analog pins as digital I/O

// A6-A11 share with digital pins

static const uint8_t A0 = 22;

static const uint8_t A1 = 23;

static const uint8_t A2 = 24;

static const uint8_t A3 = 25;

#define digitalPinToPCICR(p) ((((p) >= 0 && (p) <= 4) || ((p) >= 8 && (p) <= 10) ) ? (&PCICR) : ((uint8_t *)0))

#define digitalPinToPCICRbit(p) 0

#define digitalPinToPCMSK(p) ((((p) >= 0 && (p) <= 4) || ((p) >= 8 && (p) <= 10) ) ? (&PCMSK0) : ((uint8_t *)0))

#define digitalPinToPCMSKbit(p) ( (p) == 0 ? 0 :(p) == 1 ? 7 :(p) == 2 ? 3 :(p) == 3 ? 1 :(p) == 4 ? 2 :(p) == 8 ? 4 :(p) == 9 ? 5 :(p) == 10 ? 6 : 0 )

//__AVR_ATmega32U4__ has an unusual mapping of pins to channels

extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];

#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )

#ifdef ARDUINO_MAIN

const uint16_t PROGMEM port_to_mode_PGM[] = {

NOT_A_PORT,

NOT_A_PORT,

(uint16_t) &DDRB,

(uint16_t) &DDRC,

(uint16_t) &DDRD,

(uint16_t) &DDRE,

(uint16_t) &DDRF,

};

const uint16_t PROGMEM port_to_output_PGM[] = {

NOT_A_PORT,

NOT_A_PORT,

(uint16_t) &PORTB,

(uint16_t) &PORTC,

(uint16_t) &PORTD,

(uint16_t) &PORTE,

(uint16_t) &PORTF,

};

const uint16_t PROGMEM port_to_input_PGM[] = {

NOT_A_PORT,

NOT_A_PORT,

(uint16_t) &PINB,

(uint16_t) &PINC,

(uint16_t) &PIND,

(uint16_t) &PINE,

(uint16_t) &PINF,

};

const uint8_t PROGMEM digital_pin_to_port_PGM[] = {

PB, //#0 LCD_RS

PB,

PB,

PB,

PB,

PD, //#5

PD,

PD,

PB,

PB,

PB,

PC,

PC,

PE, //#13 LCD_E

PD, //ERROR

PD, //ACK

PD,

PE,

PF,

PF,

PD,

PD,

PF,//#22

PF,

PF,

PF,

};

const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {

_BV(0), //LCD_RS

_BV(7),

_BV(3),

_BV(1),

_BV(2),

_BV(4),

_BV(6),

_BV(7),

_BV(4),

_BV(5),

_BV(6),

_BV(6),

_BV(7),

_BV(6), //LCD_E

_BV(0),

_BV(1),

_BV(5),

_BV(2),

_BV(7),

_BV(6),

_BV(3), //TXD

_BV(2), //RXD

_BV(0), //#22 ADC0

_BV(1),

_BV(4),

_BV(5),

};

const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {

NOT_ON_TIMER,

TIMER0A,

NOT_ON_TIMER,

NOT_ON_TIMER,/* 3 */

NOT_ON_TIMER,

NOT_ON_TIMER,/* 5 */

NOT_ON_TIMER,/* 6 */

TIMER4D,

NOT_ON_TIMER,

TIMER1A,/* 9 */

TIMER1B,/* 10 */

TIMER3A,/* 11 */

TIMER4A,

NOT_ON_TIMER,/* 13 */

TIMER0B,

NOT_ON_TIMER,

NOT_ON_TIMER,

NOT_ON_TIMER,

NOT_ON_TIMER,

NOT_ON_TIMER,

NOT_ON_TIMER, /* 20 */

NOT_ON_TIMER,

NOT_ON_TIMER,

NOT_ON_TIMER,

NOT_ON_TIMER,

NOT_ON_TIMER,

};

const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {

0,// A0

1,// A1

4,// A2

5,// A3

};

#endif /* ARDUINO_MAIN */

#endif /* Pins_Arduino_h */



3) Altere o arquivo preferences.txt (..\lib) para que o programa coloque o arquivo de gravação .hex na pasta raiz\Arduino_hex. O arquivo de gravação será utilizado pelo software Flip para enviar o código para placa Lab_Uino.


# temporary build path, normally this goes into the default

# "temp" folder for that platform (as defined by java)

# but this can be used to set a specific file in case of problems

build.path=/Arduino_hex