sys_log: Grove driver update to new logging API
Replaces old DBG calls by new SYS_LOG_... ones, likewise updates the grove/Kconfig file to include new per-level logging control. Change-Id: I638ffa915a760b4f188c1bfa2dc68e63cbf7e624 Signed-off-by: Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com>
This commit is contained in:
parent
34d497118a
commit
d1e9181fd4
2 changed files with 29 additions and 29 deletions
|
@ -22,13 +22,23 @@ menuconfig GROVE
|
||||||
prompt "Grove Device Drivers"
|
prompt "Grove Device Drivers"
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Check this box to enable the Seeed Grove device drivers
|
Check this box to enable the Seeed Grove device drivers
|
||||||
|
|
||||||
config GROVE_DEBUG
|
|
||||||
bool
|
config SYS_LOG_GROVE_LEVEL
|
||||||
prompt "Enable Grove debug messagings"
|
int
|
||||||
default n
|
prompt "Grove Log level"
|
||||||
depends on GROVE
|
depends on SYS_LOG && GROVE
|
||||||
|
default 0
|
||||||
|
range 0 4
|
||||||
|
help
|
||||||
|
Sets log level for Grove Device Drivers.
|
||||||
|
Levels are:
|
||||||
|
0 OFF, do not write
|
||||||
|
1 ERROR, only write SYS_LOG_ERR
|
||||||
|
2 WARNING, write SYS_LOG_WRN in adition to previous level
|
||||||
|
3 INFO, write SYS_LOG_INF in adition to previous levels
|
||||||
|
4 DEBUG, write SYS_LOG_DBG in adition to previous levels
|
||||||
|
|
||||||
config GROVE_LCD_RGB
|
config GROVE_LCD_RGB
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -27,23 +27,15 @@
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <display/grove_lcd.h>
|
#include <display/grove_lcd.h>
|
||||||
|
|
||||||
|
#define SYS_LOG_DOMAIN "Grove LCD"
|
||||||
|
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_GROVE_LEVEL
|
||||||
|
#include <misc/sys_log.h>
|
||||||
|
|
||||||
#define SLEEP_IN_US(_x_) ((_x_) * 1000)
|
#define SLEEP_IN_US(_x_) ((_x_) * 1000)
|
||||||
|
|
||||||
#define GROVE_LCD_DISPLAY_ADDR (0x3E)
|
#define GROVE_LCD_DISPLAY_ADDR (0x3E)
|
||||||
#define GROVE_RGB_BACKLIGHT_ADDR (0x62)
|
#define GROVE_RGB_BACKLIGHT_ADDR (0x62)
|
||||||
|
|
||||||
#ifndef CONFIG_GROVE_DEBUG
|
|
||||||
#define DBG(...) { ; }
|
|
||||||
#else
|
|
||||||
#if defined(CONFIG_STDOUT_CONSOLE)
|
|
||||||
#include <stdio.h>
|
|
||||||
#define DBG printf
|
|
||||||
#else
|
|
||||||
#include <misc/printk.h>
|
|
||||||
#define DBG printk
|
|
||||||
#endif /* CONFIG_STDOUT_CONSOLE */
|
|
||||||
#endif /* CONFIG_GROVE_DEBUG */
|
|
||||||
|
|
||||||
struct command {
|
struct command {
|
||||||
uint8_t control;
|
uint8_t control;
|
||||||
uint8_t data;
|
uint8_t data;
|
||||||
|
@ -168,7 +160,7 @@ void glcd_clear(struct device *port)
|
||||||
uint8_t clear[] = { 0, GLCD_CMD_SCREEN_CLEAR };
|
uint8_t clear[] = { 0, GLCD_CMD_SCREEN_CLEAR };
|
||||||
|
|
||||||
i2c_write(dev->i2c, clear, sizeof(clear), rom->lcd_addr);
|
i2c_write(dev->i2c, clear, sizeof(clear), rom->lcd_addr);
|
||||||
DBG("Grove LCD: clear, delay 20 ms\n");
|
SYS_LOG_DBG("clear, delay 20 ms");
|
||||||
_sleep(20);
|
_sleep(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +177,7 @@ void glcd_display_state_set(struct device *port, uint8_t opt)
|
||||||
|
|
||||||
i2c_write(dev->i2c, data, sizeof(data), rom->lcd_addr);
|
i2c_write(dev->i2c, data, sizeof(data), rom->lcd_addr);
|
||||||
|
|
||||||
DBG("Grove LCD: set display_state options, delay 5 ms\n");
|
SYS_LOG_DBG("set display_state options, delay 5 ms");
|
||||||
_sleep(5);
|
_sleep(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +201,7 @@ void glcd_input_state_set(struct device *port, uint8_t opt)
|
||||||
|
|
||||||
i2c_write(dev->i2c, &dev->input_set, sizeof(dev->input_set),
|
i2c_write(dev->i2c, &dev->input_set, sizeof(dev->input_set),
|
||||||
rom->lcd_addr);
|
rom->lcd_addr);
|
||||||
DBG("Grove LCD: set the input_set, no delay\n");
|
SYS_LOG_DBG("set the input_set, no delay");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -223,12 +215,10 @@ uint8_t glcd_input_state_get(struct device *port)
|
||||||
|
|
||||||
void glcd_color_select(struct device *port, uint8_t color)
|
void glcd_color_select(struct device *port, uint8_t color)
|
||||||
{
|
{
|
||||||
#if CONFIG_GROVE_DEBUG
|
|
||||||
if (color > 3) {
|
if (color > 3) {
|
||||||
DBG("%s : selected color is too high a value\n", __func__);
|
SYS_LOG_WRN("selected color is too high a value");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
glcd_color_set(port, color_define[color][0],
|
glcd_color_set(port, color_define[color][0],
|
||||||
color_define[color][1],
|
color_define[color][1],
|
||||||
color_define[color][2]);
|
color_define[color][2]);
|
||||||
|
@ -256,7 +246,7 @@ void glcd_function_set(struct device *port, uint8_t opt)
|
||||||
|
|
||||||
i2c_write(dev->i2c, data, sizeof(data), rom->lcd_addr);
|
i2c_write(dev->i2c, data, sizeof(data), rom->lcd_addr);
|
||||||
|
|
||||||
DBG("Grove LCD: set function options, delay 5 ms\n");
|
SYS_LOG_DBG("set function options, delay 5 ms");
|
||||||
_sleep(5);
|
_sleep(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +264,7 @@ int glcd_initialize(struct device *port)
|
||||||
struct glcd_data *dev = port->driver_data;
|
struct glcd_data *dev = port->driver_data;
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
|
|
||||||
DBG("Grove LCD: initialize called\n");
|
SYS_LOG_DBG("initialize called");
|
||||||
|
|
||||||
dev->input_set = 0;
|
dev->input_set = 0;
|
||||||
dev->display_switch = 0;
|
dev->display_switch = 0;
|
||||||
|
@ -310,7 +300,7 @@ int glcd_initialize(struct device *port)
|
||||||
* We're here! Let's just make sure we've had enough time for the
|
* We're here! Let's just make sure we've had enough time for the
|
||||||
* VDD to power on, so pause a little here, 30 ms min, so we go 50
|
* VDD to power on, so pause a little here, 30 ms min, so we go 50
|
||||||
*/
|
*/
|
||||||
DBG("Grove LCD: delay 50 ms while the VDD powers on\n");
|
SYS_LOG_DBG("delay 50 ms while the VDD powers on");
|
||||||
_sleep(50);
|
_sleep(50);
|
||||||
|
|
||||||
/* Configure everything for the display function first */
|
/* Configure everything for the display function first */
|
||||||
|
@ -331,13 +321,13 @@ int glcd_initialize(struct device *port)
|
||||||
glcd_input_state_set(port, cmd);
|
glcd_input_state_set(port, cmd);
|
||||||
|
|
||||||
/* Now power on the background RGB control */
|
/* Now power on the background RGB control */
|
||||||
DBG("Grove LCD: configuring the RGB background\n");
|
SYS_LOG_INF("configuring the RGB background");
|
||||||
_rgb_reg_set(dev->i2c, 0x00, 0x00);
|
_rgb_reg_set(dev->i2c, 0x00, 0x00);
|
||||||
_rgb_reg_set(dev->i2c, 0x01, 0x05);
|
_rgb_reg_set(dev->i2c, 0x01, 0x05);
|
||||||
_rgb_reg_set(dev->i2c, 0x08, 0xAA);
|
_rgb_reg_set(dev->i2c, 0x08, 0xAA);
|
||||||
|
|
||||||
/* Now set the background color to white */
|
/* Now set the background color to white */
|
||||||
DBG("Grove LCD: background set to white\n");
|
SYS_LOG_DBG("background set to white");
|
||||||
_rgb_reg_set(dev->i2c, REGISTER_R, color_define[GROVE_RGB_WHITE][0]);
|
_rgb_reg_set(dev->i2c, REGISTER_R, color_define[GROVE_RGB_WHITE][0]);
|
||||||
_rgb_reg_set(dev->i2c, REGISTER_G, color_define[GROVE_RGB_WHITE][1]);
|
_rgb_reg_set(dev->i2c, REGISTER_G, color_define[GROVE_RGB_WHITE][1]);
|
||||||
_rgb_reg_set(dev->i2c, REGISTER_B, color_define[GROVE_RGB_WHITE][2]);
|
_rgb_reg_set(dev->i2c, REGISTER_B, color_define[GROVE_RGB_WHITE][2]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue