1 /* 2 * SPDX-License-Identifier: Apache-2.0 3 * Copyright (C) 2022, Intel Corporation 4 * Description: 5 * Example to use LCD disply in Cyclone V SoC DevKit 6 * Reference: https://datasheetspdf.com/pdf-file/746090/Newhaven/NHD-0216K3Z-NSW-BBW/1 7 */ 8 9 /* Insert Prefix 0xFE before executing command */ 10 #define DISPLAY_ON 0x41 11 #define DISPLAY_OFF 0x42 12 #define SET_CURSOR 0x45 /*1 byte param in range (0x00 - 0x4F) 2x16 display */ 13 #define CURSOR_HOME 0x46 14 #define UNDERLINE_ON 0x47 15 #define UNDERLINE_OFF 0x48 16 #define MOVE_CUR_LEFT 0x49 17 #define MOVE_CUR_RIGHT 0x4a 18 #define BLINK_ON 0x4b 19 #define BLINK_OFF 0x4c 20 #define BACKSPACE 0x4e 21 #define CLEAR_SCREEN 0x51 22 #define SET_CONTRAST 0x52 /* 1 byte param in range (1 - 50) 40 default */ 23 #define SET_BACKLIGHT 0x53 /* 1 byte param in range (1 - 8) 1 default */ 24 25 #define LD_CUSTOM_CHAR 0x54 /* 9 byte param 1st param: 1-byte */ 26 27 /* Syntax prefix LD_CUSTOM_CHAR [addr] [d0 …d7] 28 * 29 * Parameter Length Description 30 * [addr] 1 byte Custom character address, 0 – 7 31 * [D0...D7] 8 bytes Custom character pattern bit map 32 * 33 * Example: ¿ Character 34 * Bit 7 6 5 4 3 2 1 0 Hex 35 * Byte1 0 0 0 0 0 1 0 0 0x04 36 * Byte2 0 0 0 0 0 0 0 0 0x00 37 * Byte3 0 0 0 0 0 1 0 0 0x04 38 * Byte4 0 0 0 0 1 0 0 0 0x08 39 * Byte5 0 0 0 1 0 0 0 0 0x10 40 * Byte6 0 0 0 1 0 0 0 1 0x11 41 * Byte7 0 0 0 0 1 1 1 0 0x0E 42 * Byte8 0 0 0 0 0 0 0 0 0x00 43 */ 44 45 #define MOVE_DISP_LEFT 0x55 46 #define MOVE_DISP_RIGHT 0x56 47 #define CHGE_RS232_BAUD 0x61 /* 1 byte param in range (1 - 8) */ 48 49 /* Syntax prefix CHGE_RS232_BAUD [param] 50 * 51 * Param BAUD 52 * 1 300 53 * 2 1200 54 * 3 2400 55 * 4 9600 56 * 5 14400 57 * 6 19.2K 58 * 7 57.6K 59 * 8 115.2K 60 */ 61 62 #define CHGE_I2C_ADDR 0X62 /* 1 byte param in range (0x00 - 0xFE), LSB = 0 */ 63 #define DISP_FIRMW_VER 0x70 64 #define DISP_RS232_BAUD 0x71 65 #define DISP_I2C_ADDR 0x72 66 67 /* Functions definitions */ 68 69 void send_ascii(char c); 70 71 void send_string(uint8_t *str_ptr, int len); 72 73 void send_command_no_param(uint8_t command_id); 74 75 void send_command_one_param(uint8_t command_id, uint8_t param); 76 77 void clear(void); 78 79 void next_line(void); 80