Uno_24 def, how alter for duemilanove?
hi,
i'm trying hard lcds work arduino
yet being newb, have trouble in understanding code, well, example learn from
i couldn't find google, should make driver compatible lcd, when driver has been made compatible uno 2.4 board duemilanove.
i'd happy if please give me idea, start...i hardly understand code found in lib, understand pin conversion. should possibly change duemilanove please?
i'm trying hard lcds work arduino
yet being newb, have trouble in understanding code, well, example learn from
i couldn't find google, should make driver compatible lcd, when driver has been made compatible uno 2.4 board duemilanove.
i'd happy if please give me idea, start...i hardly understand code found in lib, understand pin conversion. should possibly change duemilanove please?
code: [select]
#ifndef _uno_24_shield_
#define _uno_24_shield_
// code provided smoke , wires
// http://www.smokeandwires.co.nz
// code has been taken adafruit tft library , modified
// use our tft shields / modules
// original code / licensing please refer to
// https://github.com/adafruit/tftlcd-library
// header file serves 2 purposes:
//
// 1) isolate non-portable mcu port- , pin-specific identifiers and
// operations library code remains agnostic
// (ports , pin numbers referenced through macros).
//
// 2) gcc doesn't respect "inline" keyword, a
// ham-fisted manner of forcing issue minimize function calls.
// makes library bit bigger before, fast++.
// however, because they're macros, need super careful about
// parameters -- example, write8(x) may expand multiple port
// writes refer x, needs constant or fixed
// variable , not *ptr++ (which, after macro
// expansion, may increment pointer repeatedly , run off into
// la-la land). macros give fine-grained control on which
// operations inlined on boards (balancing speed against
// available program space).
// smoke , wires 2.4 shield pin usage:
// lcd data bit : 7 6 5 4 3 2 1 0
// digital pin #: 7 6 5 4 3 2 9 8
// uno port/pin : pd7 pd6 pd5 pd4 pd3 pd2 pb1 pb0
#define lcd_cs a3 // chip select goes analog 3
#define lcd_cd a2 // command/data goes analog 2
#define lcd_wr a1 // lcd write goes analog 1
#define lcd_rd a0 // lcd read goes analog 0
#define lcd_reset a4 // can alternately connect arduino's reset pin
// pixel read operations require minimum 400 ns delay rd_active
// polling input pins. @ 16 mhz, 1 machine cycle 62.5 ns.
// code burns 7 cycles (437.5 ns) doing nothing; rjmps are
// equivalent 2 nops each, final nop burns 7th cycle, , the
// last line radioactive mutant emoticon.
#define delay7 \
asm volatile( \
"rjmp .+0" "\n\t" \
"rjmp .+0" "\n\t" \
"rjmp .+0" "\n\t" \
"nop" "\n" \
::);
// // these set port directions required before write , read
// // operations. because write operations more common reads,
// // data-reading functions in library code set port(s) to
// // input before read, , restore them write state before
// // returning. avoids having set output inside every
// // drawing method. default state has them initialized writes.
// #define setwritedirinline() { ddrd |= b11010000; ddrb |= b00101111; }
// #define setreaddirinline() { ddrd &= ~b11010000; ddrb &= ~b00101111; }
//
#define write8inline(d) { \
portd = (portd & b00000011) | ((d) & b11111100); \
portb = (portb & b11111100) | ((d) & b00000011); \
wr_strobe; }
#define read8inline(result) { \
rd_active; \
delay7; \
result = (pind & b11111100) | (pinb & b00000011); \
rd_idle; }
#define setwritedirinline() { ddrd |= b11111100; ddrb |= b00000011; }
#define setreaddirinline() { ddrd &= ~b11111100; ddrb &= ~b00000011; }
// part of inline control, macros reference other macros...if any
// of these left undefined, equivalent function version (non-inline)
// declared later. uno has moderate amount of program space, so
// write8() inlined -- 1 provides performance
// benefit, unfortunately generates bloat. is
// why cases inlined each board.
#define write8 write8inline
// when using tft breakout board, control pins configurable.
#define rd_active *rdport &= rdpinunset
#define rd_idle *rdport |= rdpinset
#define wr_active *wrport &= wrpinunset
#define wr_idle *wrport |= wrpinset
#define cd_command *cdport &= cdpinunset
#define cd_data *cdport |= cdpinset
#define cs_active *csport &= cspinunset
#define cs_idle *csport |= cspinset
// #endif
// #endif
// data write strobe, ~2 instructions , inline
#define wr_strobe { wr_active; wr_idle; }
// these higher-level operations functionalized,
// except on mega where's there's gobs , gobs of program space.
// set value of tft register: 8-bit address, 8-bit value
#define writeregister8inline(a, d) { \
cd_command; write8(a); cd_data; write8(d); }
// set value of tft register: 16-bit address, 16-bit value
// see notes @ top macro expansion, hence hi & lo temp vars
#define writeregister16inline(a, d) { \
uint8_t hi, lo; \
hi = (a) >> 8; lo = (a); cd_command; write8(hi); write8(lo); \
hi = (d) >> 8; lo = (d); cd_data ; write8(hi); write8(lo); }
// set value of 2 tft registers: 2 8-bit addresses (hi & lo), 16-bit value
#define writeregisterpairinline(ah, al, d) { \
uint8_t hi = (d) >> 8, lo = (d); \
cd_command; write8(ah); cd_data; write8(hi); \
cd_command; write8(al); cd_data; write8(lo); }
#endif // _uuno_24_shield_
quote
when driver has been made compatible uno 2.4 board duemilanove.what heck uno 2.4?
Arduino Forum > Using Arduino > Programming Questions > Uno_24 def, how alter for duemilanove?
arduino
Comments
Post a Comment