hadif azli / Mbed 2 deprecated TEST123

Dependencies:   mbed Blynk

Revision:
2:6cd3b0947188
Parent:
1:0e75de2a5d21
Child:
3:4cd9171ba989
--- a/u8glibARM/u8g_com_lpc824_ssd_i2c.c	Mon Jun 13 02:21:11 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,202 +0,0 @@
-#include "u8g.h"
-#include "i2c_api.h"
-
-//extern gpio_t g_LED;
-//extern int i2c_write(int address, const char *data, int length);
-i2c_t _i2c;
-static uint8_t isCmd = 1;
-//#define I2C_SLA     (0x3c*2)
-uint8_t I2C_SLA = 0x3C << 1;
-//#define I2C_CMD_MODE  0x080
-#define I2C_CMD_MODE    0x00
-#define I2C_DATA_MODE   0x40
-
-uint8_t u8g_com_lpc824_ssd_start_sequence(u8g_t *u8g)
-{
-#if 0
-    /* are we requested to set the a0 state? */
-    if ( u8g->pin_list[U8G_PI_SET_A0] == 0 )
-        return 1;
-
-    /* setup bus, might be a repeated start */
-    if ( u8g_i2c_start(I2C_SLA) == 0 )
-        return 0;
-    if ( u8g->pin_list[U8G_PI_A0_STATE] == 0 ) {
-        if ( u8g_i2c_send_byte(I2C_CMD_MODE) == 0 )
-            return 0;
-    } else {
-        if ( u8g_i2c_send_byte(I2C_DATA_MODE) == 0 )
-            return 0;
-    }
-
-    u8g->pin_list[U8G_PI_SET_A0] = 0;
-    return 1;
-#else
-    char cmd;
-    if (isCmd == 1) {
-        cmd = I2C_CMD_MODE;
-        int cmdRet = i2c_write(&_i2c, I2C_SLA, &cmd, 1, 0);
-    } else {
-        cmd = I2C_DATA_MODE;
-        int cmdRet = i2c_write(&_i2c, I2C_SLA, &cmd, 1, 0);
-    }
-    
-    //printf("isCmd = %d, cmdRet = %d\r\n", isCmd, cmdRet);
-    return 0;
-#endif
-}
-
-uint8_t u8g_com_lpc824_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
-{
-    static uint8_t ifFirst = 0;
-    switch(msg) {
-        case U8G_COM_MSG_INIT:
-            if (ifFirst == 0) {
-                //printf("U8G_COM_MSG_INIT:_i2c = 0x%x\r\n", &_i2c);
-                //u8g_com_arduino_digital_write(u8g, U8G_PI_SCL, HIGH);
-                //u8g_com_arduino_digital_write(u8g, U8G_PI_SDA, HIGH);
-                //u8g->pin_list[U8G_PI_A0_STATE] = 0;       /* inital RS state: unknown mode */
-#if 0
-                u8g_i2c_init(u8g->pin_list[U8G_PI_I2C_OPTION]);
-#else
-                i2c_init(&_i2c, P0_11, P0_10);
-                printf("_i2c = 0x%x, I2C_SLA = 0x%x\r\n", &_i2c, I2C_SLA);
-                
-#endif
-                ifFirst = 1;
-            }
-            break;
-
-        case U8G_COM_MSG_STOP:
-            printf("U8G_COM_MSG_STOP\r\n");
-            break;
-
-        case U8G_COM_MSG_RESET:
-            /* Currently disabled, but it could be enable. Previous restrictions have been removed */
-            /* u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val); */
-            printf("U8G_COM_MSG_RESET\r\n");
-            i2c_reset(&_i2c);
-            break;
-
-        case U8G_COM_MSG_CHIP_SELECT:
-#if 0
-            u8g->pin_list[U8G_PI_A0_STATE] = 0;
-            u8g->pin_list[U8G_PI_SET_A0] = 1;     /* force a0 to set again, also forces start condition */
-            if ( arg_val == 0 ) {
-                /* disable chip, send stop condition */
-                u8g_i2c_stop();
-            } else {
-                /* enable, do nothing: any byte writing will trigger the i2c start */
-            }
-            #else
-            //printf("U8G_COM_MSG_CHIP_SELECT\r\n");
-#endif
-            break;
-
-        case U8G_COM_MSG_WRITE_BYTE:
-#if 0
-            //u8g->pin_list[U8G_PI_SET_A0] = 1;
-            if ( u8g_com_lpc824_ssd_start_sequence(u8g) == 0 )
-                return u8g_i2c_stop(), 0;
-            if ( u8g_i2c_send_byte(arg_val) == 0 )
-                return u8g_i2c_stop(), 0;
-            // u8g_i2c_stop();
-#else
-            u8g_com_lpc824_ssd_start_sequence(u8g);
-            i2c_write(&_i2c, I2C_SLA, &arg_val, 1, 1);
-            //printf("arg_val = 0x%x\r\n", arg_val);
-#endif
-            break;
-
-        case U8G_COM_MSG_WRITE_SEQ:
-#if 0
-            //u8g->pin_list[U8G_PI_SET_A0] = 1;
-            if ( u8g_com_lpc824_ssd_start_sequence(u8g) == 0 )
-                return u8g_i2c_stop(), 0;
-            {
-                register uint8_t *ptr = arg_ptr;
-                while( arg_val > 0 ) {
-                    if ( u8g_i2c_send_byte(*ptr++) == 0 )
-                        return u8g_i2c_stop(), 0;
-                    arg_val--;
-                }
-            }
-            // u8g_i2c_stop();
-#else
-            u8g_com_lpc824_ssd_start_sequence(u8g);
-            {
-                char *ptr = arg_ptr;
-                int ret = i2c_write(&_i2c, I2C_SLA, ptr, arg_val, 1);
-                //printf("ret = %d, arg_val = %d\r\n", ret, arg_val);
-            }
-#endif
-            break;
-
-        case U8G_COM_MSG_WRITE_SEQ_P:
-#if 0
-            //u8g->pin_list[U8G_PI_SET_A0] = 1;
-            if ( u8g_com_lpc824_ssd_start_sequence(u8g) == 0 )
-                return u8g_i2c_stop(), 0;
-            {
-                register uint8_t *ptr = arg_ptr;
-                while( arg_val > 0 ) {
-                    if ( u8g_i2c_send_byte(u8g_pgm_read(ptr)) == 0 )
-                        return 0;
-                    ptr++;
-                    arg_val--;
-                }
-            }
-            // u8g_i2c_stop();
-#else
-            u8g_com_lpc824_ssd_start_sequence(u8g);
-            {
-                register uint8_t *ptr = arg_ptr;
-                int r = i2c_write(&_i2c, I2C_SLA, ptr, arg_val, 1);
-                if (r == arg_val) {
-                    //gpio_write(&g_LED, 1);
-                }
-                //printf("r = %d\r\n", r);
-            }
-#endif
-            break;
-
-        case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
-            //u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
-            //u8g->pin_list[U8G_PI_SET_A0] = 1;     /* force a0 to set again */
-            if (arg_val == 1) {
-                isCmd = 0;
-            } else {
-                isCmd = 1;
-            }
-#ifdef OLD_CODE
-            if ( i2c_state != 0 ) {
-                u8g_i2c_stop();
-                i2c_state = 0;
-            }
-
-            if ( u8g_com_arduino_ssd_start_sequence(arg_val) == 0 )
-                return 0;
-
-            /* setup bus, might be a repeated start */
-            /*
-            if ( u8g_i2c_start(I2C_SLA) == 0 )
-            return 0;
-            if ( arg_val == 0 )
-            {
-            i2c_state = 1;
-
-            if ( u8g_i2c_send_byte(I2C_CMD_MODE) == 0 )
-            return 0;
-            }
-            else
-            {
-            i2c_state = 2;
-            if ( u8g_i2c_send_byte(I2C_DATA_MODE) == 0 )
-            return 0;
-            }
-            */
-#endif
-            break;
-    }
-    return 1;
-}