From 12cf816b5b5f949b5384fbce3c3cc9718a9cd084 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 8 Sep 2015 00:40:50 +0100 Subject: working displat and cg-rom --- bsp/bracelet.h | 6 +- crypto/gt22l16a1y.c | 30 +++++++--- crypto/prototypes.h | 3 +- crypto/ssd1306.c | 138 ++++++++++++++++++++++++++++++++++++--------- reverse_engineering/pinmap | 47 ++++++++------- 5 files changed, 161 insertions(+), 63 deletions(-) diff --git a/bsp/bracelet.h b/bsp/bracelet.h index dc1e7d0..d7c983e 100644 --- a/bsp/bracelet.h +++ b/bsp/bracelet.h @@ -48,10 +48,8 @@ #define BUTTONS_MASK (BSP_BUTTON_0_MASK|BSP_BUTTON_1_MASK) -#define RX_PIN_NUMBER 18 -#define TX_PIN_NUMBER 19 -//#define CTS_PIN_NUMBER 10 -//#define RTS_PIN_NUMBER 8 +#define RX_PIN_NUMBER 10 +#define TX_PIN_NUMBER 11 #define HWFC false #if 0 diff --git a/crypto/gt22l16a1y.c b/crypto/gt22l16a1y.c index b997c36..4ee50a1 100644 --- a/crypto/gt22l16a1y.c +++ b/crypto/gt22l16a1y.c @@ -1,7 +1,12 @@ #include "project.h" -#define SCLK 17 -#define MOSI 18 +// P0.20 => ginatop pin 8 MISO +// P0.19 => ginatop pin 7 CS +// P0.18 => ginatop pin 4 SCLK +// P0.17 => ginatop pin 3 MOSI + +#define MOSI 17 +#define SCLK 18 #define NCS 19 #define MISO 20 @@ -55,7 +60,7 @@ gt_init (void) NRF_GPIO->OUTSET = (1 << NCS) | (1<OUTCLR = (1 << SCLK); d(); NRF_GPIO->OUTCLR = (1 << NCS); - NRF_GPIO->OUTSET = (1 << NCS); + //NRF_GPIO->OUTSET = (1 << NCS); d(); a |= READ << 24; - a=0x3000000; - a+=768+80; - for (c=0x80000000;c;c>>=1) { if (c&a) NRF_GPIO->OUTSET = (1 << MOSI); @@ -107,3 +109,17 @@ void gt_read(uint32_t a,uint8_t * buf,size_t len) } +void gt_read_8x8(uint32_t c,uint8_t *d,size_t l) +{ +if (c<0x20) c=0x20; +if (c>0x7e) c=0x20; + +c-=0x20; + +c*=8; +c+=768; + +gt_read(c,d,l); +} + + diff --git a/crypto/prototypes.h b/crypto/prototypes.h index ddff112..509dbc6 100644 --- a/crypto/prototypes.h +++ b/crypto/prototypes.h @@ -1,5 +1,6 @@ /* ssd1306.c */ extern void sd_on(void); +extern void sd_putstr(char *s, int x, int y); extern void sd_doodle(void); extern void sd_init(void); /* rng.c */ @@ -7,7 +8,7 @@ extern uint8_t random_vector_generate(uint8_t *p_buff, uint8_t size); extern void rng_init(void); /* gt22l16a1y.c */ extern void gt_init(void); -extern void gt_read(uint32_t a, uint8_t *buf, size_t len); +extern void gt_read_8x8(uint32_t c, uint8_t *d, size_t l); /* main.c */ extern void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name); extern int main(void); diff --git a/crypto/ssd1306.c b/crypto/ssd1306.c index 7421669..4b009b2 100644 --- a/crypto/ssd1306.c +++ b/crypto/ssd1306.c @@ -182,12 +182,61 @@ sd_cmd (uint8_t c) } + +static uint8_t cur_x; +static uint8_t cur_y; + static int sd_dat (uint8_t c) { + cur_x++; return sd_write (1, c); } +static int +sd_dat0s (size_t len) +{ + int ret = 0; + + i2c_start (); + + i2c_send_byte (SAD | WRITE); + ret |= i2c_recv_ack (); + i2c_send_byte (0x40); + ret |= i2c_recv_ack (); + + while (len--) { + i2c_send_byte (0); + ret |= i2c_recv_ack (); + cur_x++; + } + i2c_stop (); + + return ret; +} + +static int +sd_dats (uint8_t *v,size_t len) +{ + int ret = 0; + + i2c_start (); + + i2c_send_byte (SAD | WRITE); + ret |= i2c_recv_ack (); + i2c_send_byte (0x40); + ret |= i2c_recv_ack (); + + while (len--) { + i2c_send_byte (*(v++)); + ret |= i2c_recv_ack (); + cur_x++; + } + i2c_stop (); + + return ret; +} + static int @@ -209,6 +258,8 @@ sd_cols (uint8_t s, uint8_t e) ret |= sd_cmd (s); ret |= sd_cmd (e); + cur_x=s; + return ret; } @@ -222,10 +273,68 @@ sd_rows (uint8_t s, uint8_t e) ret |= sd_cmd (s); ret |= sd_cmd (e); + cur_y=s; + return ret; } +void sd_putstr(char *s,int x,int y) +{ +static uint8_t d[8]; + +while (*s) { + +if (x!=cur_x) + sd_cols (x, 127); +if (y!=cur_y) + sd_rows (y, 3); + +gt_read_8x8(*s,d,sizeof(d)); +sd_dats(d,sizeof(d)); + +x+=8; + +if (x==128) { + x=0; + y++; +} + +if (y==4) + y=0; + + +s++; +} + +} + + +void sd_cls(void) +{ + + sd_cols (0, 127); + sd_rows (0, 3); + + sd_dat0s(128*4); + +} + +void +sd_doodle (void) +{ +//static uint8_t d[8]; + +sd_putstr("Fishsoup",0,0); + + +//gt_read_8x8('f',d,sizeof(d)); +//sd_dats(d,sizeof(d)); + + +} + + void sd_on (void) { @@ -300,33 +409,8 @@ sd_on (void) sd_address_mode (0); sd_cols (0, 127); - sd_rows (0, 63); -} - -void -sd_doodle (void) -{ - static uint8_t d[8]; - random_vector_generate(d,1); - uint32_t a; - - - a=d[0]; - a%=63; - a*=8; - a+=768; - - gt_read(a,d,sizeof(d)); - - - sd_dat (d[0]); - sd_dat (d[1]); - sd_dat (d[2]); - sd_dat (d[3]); - sd_dat (d[4]); - sd_dat (d[5]); - sd_dat (d[6]); - sd_dat (d[7]); + sd_rows (0, 3); + sd_cls(); } diff --git a/reverse_engineering/pinmap b/reverse_engineering/pinmap index bbc0601..d7b6c9b 100644 --- a/reverse_engineering/pinmap +++ b/reverse_engineering/pinmap @@ -39,46 +39,45 @@ P0.29 => 00000004, INPUT, CONNECT INPUT, PULL DOWN, STANDARD DRIVE, NO SENSE P0.30 => 00000003, OUTPUT, NO INPUT, PULL DOWN, STANDARD DRIVE, NO SENSE P0.31 => 00000004, INPUT, CONNECT INPUT, PULL DOWN, STANDARD DRIVE, NO SENSE -P0.31 => IN -P0.30 => OUT screen reset -P0.29 => IN vibrator -P0.28 => IN - -P0.27 => IN -P0.26 => IN -P0.25 => OUT screen power on/off +P0.31 => ? +P0.30 => sreen brightness +P0.29 => vibrator +P0.28 => ? + +P0.27 => ? +P0.26 => ? +P0.25 => screen power on/off P0.24 => BIDI SCL for OLED screen P0.23 => BIDI SDA for OLED screen -P0.22 => IN white LED -P0.21 => IN -P0.20 => IN G-chip - -P0.19 => OUT G-chip -P0.18 => IN G-chip -P0.17 => IN G-chip +P0.22 => white LED +P0.21 => ? +P0.20 => ginatop pin 8 MISO +P0.19 => ginatop pin 7 CS +P0.18 => ginatop pin 4 SCLK +P0.17 => ginatop pin 3 MOSI P0.16 => ? P0.15 => LIS331 interrupt pin -P0.14 => +P0.14 => ? P0.13 => BIDI SCL for LIS331 P0.12 => BIDI SDA for LIS331 -P0.11 => 0 -P0.10 => 0 +P0.11 => TX +P0.10 => RX P0.9 => BIDI SDA for AT24C256 P0.8 => BIDI SCL for AT24C256 -P0.7 => 1 interrtupt from LIS331 ? -P0.6 => 0 -P0.5 => 0 +P0.7 => interrtupt from LIS331 +P0.6 => ? +P0.5 => ? P0.4 => button P0.3 => button -P0.2 => 0 -P0.1 => 0 -P0.0 => 0 +P0.2 => ? +P0.1 => ? +P0.0 => ? SPI controllers both have psel of -1 and disabled -- cgit v1.2.3