/*
* OpenI2CRADIO
- * I2C-LCD ACM1602 Handler(Header)
+ * I2C/Parallel LCD ACM1602 Handler, variant of ST7066U.
* Copyright (C) 2013-06-10 K.Ohta <whatisthis.sowhat ai gmail.com>
* License: GPL2+LE
*
#include <stdarg.h>
#include <stdio.h>
+#ifdef __SDCC
#include <delay.h>
+#else
+#include <xc.h>
+#endif
+
#include <string.h>
#include "iodef.h"
#include "i2c_io.h"
+#include "idle.h"
#ifdef __cplusplus
extern "C" {
#endif
+#ifndef LCD_I2CADDR
+#define LCD_I2CADDR 0xa0
+#endif
// Notes: Master clock = 8MHz(0.125uS)
// Wait 5us
+#ifdef __SDCC
#define _ACM1602_TC_WAIT() delay10tcy(4)
// Wait 50us
#define _ACM1602_SHORT_WAIT() delay100tcy(4)
// Wait 5ms
-#define _ACM1602_LONG_WAIT() delay1ktcy(40)
+#define _ACM1602_LONG_WAIT() delay10ktcy(40)
+// Wait 125ms
+#define _ACM1602_LONG_LONG_WAIT() delay1mtcy(1)
+// Wait 5.5ms
+#define _ACM1602_I2C_WAIT() delay1ktcy(44)
+#else
+#define _ACM1602_TC_WAIT() __delay_us(5)
+// Wait 50us
+#define _ACM1602_SHORT_WAIT() __delay_us(50)
+// Wait 5ms
+#define _ACM1602_LONG_WAIT() __delay_ms(50)
+// Wait 125ms
+#define _ACM1602_LONG_LONG_WAIT() idle_time_ms(125)
+// Wait 5.5ms
+#define _ACM1602_I2C_WAIT() __delay_us(5500)
+#endif
-void acm1602_cls(unsigned char addr);
-void acm1602_putchar(unsigned char addr, unsigned char c);
-void acm1602_locate(unsigned char addr, char x, char y);
-void acm1602_home(unsigned char addr);
-void acm1602_printf(unsigned char addr, const char *fmt, ...);
-void acm1602_cursordir(unsigned char addr, unsigned char right);
-void acm1602_init(unsigned char addr, unsigned char cls);
+extern void acm1602_cls(unsigned char addr);
+extern void acm1602_putchar(unsigned char addr, unsigned char c);
+extern void acm1602_locate_16x2(unsigned char addr, char x, char y);
+extern void acm1602_locate_8x2(unsigned char addr, char x, char y);
+extern void acm1602_home(unsigned char addr);
+extern void acm1602_cursordir(unsigned char addr, unsigned char right);
+extern void acm1602_init(unsigned char addr, unsigned char cls);
+extern void acm1602_suspend(unsigned char addr);
+//extern unsigned char acm1602_getchar(unsigned char addr);
+#ifdef _USE_I2C_1602
+/*
+ * ST7032 extension functions
+ */
+extern void st7032_extcmd(unsigned char addr, unsigned char mode,
+ unsigned char cmd, unsigned char busyf);
+extern void st7032_setcontrast(unsigned char addr, unsigned char value,
+ unsigned char busyf);
+#endif
#ifdef __cplusplus
}
#endif