A collection of Analog Devices drivers for the mbed platform
For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
Revision 21:a8023e5e97be, committed 2016-05-17
- Comitter:
- Adrian Suciu
- Date:
- Tue May 17 18:15:28 2016 +0300
- Parent:
- 20:9790e53d6e26
- Child:
- 22:34a97378aab6
- Commit message:
- Created EVAL_ADXL362_ARDZ component and restructured code around it
Changed in this revision
--- a/examples/adxl362_example/Makefile Tue May 17 15:15:19 2016 +0300 +++ b/examples/adxl362_example/Makefile Tue May 17 18:15:28 2016 +0300 @@ -5,10 +5,10 @@ PROJECT = adxl362-MBED ADI_LIBRARIES_PATH = ../../libraries MBED_LIBRARIES_PATH = ../../mbed -OBJECTS = ./main.o ./lcd.o $(ADI_LIBRARIES_PATH)/ADXL362/ADXL362.o +OBJECTS = ./main.o $(ADI_LIBRARIES_PATH)/eval_adxl362_ardz/lcd.o $(ADI_LIBRARIES_PATH)/ADXL362/ADXL362.o $(ADI_LIBRARIES_PATH)/eval_adxl362_ardz/EVAL_ADXL362_ARDZ.o # $(ADI_LIBRARIES_PATH)/CN0216/CN0216.o SYS_OBJECTS = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ramfunc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/board.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/cmsis_nvic.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/hal_tick.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/mbed_overrides.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/retarget.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/startup_stm32f411xe.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_adc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_can.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cec.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cortex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_crc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_cryp_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dac_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dcmi_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma2d.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dma_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_dsi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_eth.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_flash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_fmpi2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_msp_template.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_gpio.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hash_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_hcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2c_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_i2s_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_irda.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_iwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_lptim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_ltdc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_smartcard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nand.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_nor.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pccard.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pcd_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_pwr_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_qspi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rcc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rng.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_rtc_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sai_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sd.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sdram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spdifrx.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_spi.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_sram.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_tim_ex.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_uart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_usart.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_hal_wwdg.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_fsmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_sdmmc.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/stm32f4xx_ll_usb.o $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/system_stm32f4xx.o -INCLUDE_PATHS = -I. -I$(MBED_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH)/adxl362 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM +INCLUDE_PATHS = -I. -I$(MBED_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH) -I$(ADI_LIBRARIES_PATH)/eval_adxl362_ardz -I$(ADI_LIBRARIES_PATH)/adxl362 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4 -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE -I$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM LIBRARY_PATHS = -L$(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM LIBRARIES = -lmbed LINKER_SCRIPT = $(MBED_LIBRARIES_PATH)/TARGET_NUCLEO_F411RE/TOOLCHAIN_GCC_ARM/STM32F411XE.ld @@ -38,9 +38,9 @@ ifeq ($(DEBUG), 1) - CC_FLAGS += -DDEBUG -O0 + CC_FLAGS += -DDEBUG -Og else - CC_FLAGS += -DNDEBUG -Os + CC_FLAGS += -DNDEBUG -Og endif .PHONY: all clean lst size
--- a/examples/adxl362_example/lcd.cpp Tue May 17 15:15:19 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,328 +0,0 @@ -/** - ****************************************************************************** - * @file Lcd.c - * @brief Source file for ST7565R LCD control. - * @author ADI - * @date March 2016 - * - ******************************************************************************* - * Copyright 2015(c) Analog Devices, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - Neither the name of Analog Devices, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - The use of this software may or may not infringe the patent rights - * of one or more patent holders. This license does not release you - * from the requirement that you obtain separate licenses from these - * patent holders to use this software. - * - Use of the software either in source or binary form, must be run - * on or directly connected to an Analog Devices Inc. component. - * - * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ******************************************************************************* - **/ - -/******************************************************************************/ -/***************************** Include Files **********************************/ -/******************************************************************************/ -#include "mbed.h" -#include "lcd.h" - - - -Lcd::Lcd(PinName rst_pin, PinName a0_pin, PinName bl_pin, - PinName cs_pin, PinName MOSI, - PinName MISO, PinName SCK) : - - rst(rst_pin), a0(a0_pin), bl(bl_pin), cs(cs_pin), lcd_spi(MOSI, MISO, SCK) -{ - rst = 1; -} - -/** - @brief Initialization of LCD screen - @return none - **/ - -void Lcd::write_cmd(uint8_t cmd) -{ - cs = 0; - a0 = 0; - lcd_spi.write(cmd); - cs = 1; -} - -void Lcd::write_data(uint8_t data) -{ - cs = 0; - a0 = 1; - lcd_spi.write(data); - cs = 1; -} - -void Lcd::bl_enable() -{ - bl = 1; -} - -void Lcd::bl_disable() -{ - bl = 0; -} - -void Lcd::init(void) -{ - - write_cmd(CMD_DISPLAY_OFF); - write_cmd(CMD_SET_BIAS_7); - write_cmd(CMD_SET_ADC_NORMAL); - write_cmd(CMD_SET_COM_REVERSE); - write_cmd((CMD_SET_RESISTOR_RATIO | 0x02)); - write_cmd(CMD_SET_VOLUME_FIRST); - write_cmd((CMD_SET_VOLUME_SECOND | 0x04)); - write_cmd((CMD_SET_POWER_CONTROL | 0x07)); - fill_pages(0, 8, 0x00); - -} - -/** - @brief Displays a string at the specified position for with 5x7 font size. - @return none - **/ -void Lcd::display_string(uint8_t ui8row, uint8_t ui8col, int8_t *pi8str) -{ - uint8_t ui8x; - uint8_t ui8i; - uint8_t ui8ch; - uint8_t ui8data; - - ui8ch = 0; - ui8x = ui8col; - - while ((pi8str[ui8ch] != 0) && (ui8col < LCD_COLUMNS)) { - set_cursor(ui8row, ui8x); /* Set cursor position */ - - for (ui8i = 0; ui8i < 5; ui8i++) { /* Symbol matrix column loop */ - ui8data = pui8font5x7[pi8str[ui8ch] - OFFS_ASCII][ui8i]; - - write_data(ui8data); - } - - ui8x += 6; /* Increase column counter with 6 pixels */ - ui8ch++; /* Increment counter */ - } - write_cmd(CMD_DISPLAY_ON); - -} - -/** - @brief Displays a symbol (8 x width) at the specified position on the LCD. - @param ui8row - row number - @param ui8col - column number - @param ui8width - symbol width - @param pui8symbol - symbol to display - @return none - **/ - -void Lcd::display_symbol(uint8_t ui8row, uint8_t ui8col, uint8_t ui8width, - const uint8_t *pui8symbol) -{ - uint8_t ui8i; - uint8_t ui8data; - - set_cursor(ui8row, ui8col); /* Set cursor position */ - for (ui8i = 0; ui8i < ui8width; ui8i++) { /* Symbol matrix column loop */ - ui8data = pui8symbol[ui8i]; - write_data(ui8data); - } - write_cmd(CMD_DISPLAY_ON); -} - -/** - @brief Fills the selected LCD pages with the data specified. - @param ui8start - start element - @param ui8num - elements numbers to fill - @param ui8Data - data to fill - @return none - **/ - -void Lcd::fill_pages(uint8_t ui8start, uint8_t ui8num, uint8_t ui8Data) -{ - - uint8_t ui8p; - uint8_t ui8c; - - for (ui8p = ui8start; ui8p < (ui8start + ui8num); ui8p++) { - set_cursor(ui8p, 0); - - for (ui8c = 0; ui8c < LCD_COLUMNS; ui8c++) { - write_data(ui8Data); - } - } - - write_cmd(CMD_DISPLAY_ON); -} - -/** - @brief Sets the start line of the LCD. - @param ui8line - line to start with - @return none - **/ - -void Lcd::set_line(uint8_t ui8line) -{ - - uint8_t ui8Cmd; - ui8Cmd = CMD_SET_DISP_START_LINE | (ui8line & 0x3F); /* Set start line */ - write_cmd(ui8Cmd); - -} - - -/** - @brief Sets the cursor position at which data will be written. - @param ui8PA - page number - @param ui8CA - column number - @return none - **/ - -void Lcd::set_cursor(uint8_t ui8PA, uint8_t ui8CA) -{ - uint8_t ui8Cmd; - - ui8Cmd = 0xB0 | (ui8PA & 0x0F); /* Set page address */ - write_cmd(ui8Cmd); - - ui8Cmd = ui8CA & 0x0F; /* Set column address LSB CA[3:0] */ - write_cmd(ui8Cmd); - - ui8Cmd = 0x10 | (ui8CA >> 4); /* Set column address MSB CA[7:4] */ - write_cmd(ui8Cmd); -} - - -const uint8_t Lcd::pui8Rec8x8[8] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; -const uint8_t Lcd::pui8RecInv8x8[8] = { - 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF -}; - -const uint8_t Lcd::pui8font5x7[96][5] = { - {0x00, 0x00, 0x00, 0x00, 0x00}, /* 32 */ - {0x00, 0x00, 0x4F, 0x00, 0x00}, /* ! 33 */ - {0x00, 0x07, 0x00, 0x07, 0x00}, /* " 34 */ - {0x14, 0x7F, 0x14, 0x7F, 0x14}, /* # 35 */ - {0x24, 0x2A, 0x7F, 0x2A, 0x12}, /* $ 36 */ - {0x23, 0x13, 0x08, 0x64, 0x62}, /* % 37 */ - {0x36, 0x49, 0x55, 0x22, 0x50}, /* & 38 */ - {0x00, 0x05, 0x03, 0x00, 0x00}, /* ' 39 */ - {0x00, 0x1C, 0x22, 0x41, 0x00}, /* ( 40 */ - {0x00, 0x41, 0x22, 0x1C, 0x00}, /* ) 41 */ - {0x14, 0x08, 0x3E, 0x08, 0x14}, /* * 42 */ - {0x08, 0x08, 0x3E, 0x08, 0x08}, /* + 43 */ - {0x00, 0x50, 0x30, 0x00, 0x00}, /* , 44 */ - {0x08, 0x08, 0x08, 0x08, 0x08}, /* - 45 */ - {0x00, 0x60, 0x60, 0x00, 0x00}, /* . 46 */ - {0x20, 0x10, 0x08, 0x04, 0x02}, /* / 47 */ - {0x3E, 0x51, 0x49, 0x45, 0x3E}, /* 0 48 */ - {0x00, 0x42, 0x7F, 0x40, 0x00}, /* 1 49 */ - {0x42, 0x61, 0x51, 0x49, 0x46}, /* 2 50 */ - {0x21, 0x41, 0x45, 0x4B, 0x31}, /* 3 51 */ - {0x18, 0x14, 0x12, 0x7F, 0x10}, /* 4 52 */ - {0x27, 0x45, 0x45, 0x45, 0x39}, /* 5 53 */ - {0x3C, 0x4A, 0x49, 0x49, 0x30}, /* 6 54 */ - {0x01, 0x71, 0x09, 0x05, 0x03}, /* 7 55 */ - {0x36, 0x49, 0x49, 0x49, 0x36}, /* 8 56 */ - {0x06, 0x49, 0x49, 0x29, 0x1E}, /* 9 57 */ - {0x36, 0x36, 0x00, 0x00, 0x00}, /* : 58 */ - {0x56, 0x36, 0x00, 0x00, 0x00}, /* ; 59 */ - {0x08, 0x14, 0x22, 0x41, 0x00}, /* < 60 */ - {0x14, 0x14, 0x14, 0x14, 0x14}, /* = 61 */ - {0x00, 0x41, 0x22, 0x14, 0x08}, /* > 62 */ - {0x02, 0x01, 0x51, 0x09, 0x06}, /* ? 63 */ - {0x30, 0x49, 0x79, 0x41, 0x3E}, /* @ 64 */ - {0x7E, 0x11, 0x11, 0x11, 0x7E}, /* A 65 */ - {0x7F, 0x49, 0x49, 0x49, 0x36}, /* B 66 */ - {0x3E, 0x41, 0x41, 0x41, 0x22}, /* C 67 */ - {0x7F, 0x41, 0x41, 0x22, 0x1C}, /* D 68 */ - {0x7F, 0x49, 0x49, 0x49, 0x41}, /* E 69 */ - {0x7F, 0x09, 0x09, 0x09, 0x01}, /* F 70 */ - {0x3E, 0x41, 0x49, 0x49, 0x7A}, /* G 71 */ - {0x7F, 0x08, 0x08, 0x08, 0x7F}, /* H 72 */ - {0x00, 0x41, 0x7F, 0x41, 0x00}, /* I 73 */ - {0x20, 0x40, 0x41, 0x3F, 0x01}, /* J 74 */ - {0x7F, 0x08, 0x14, 0x22, 0x41}, /* K 75 */ - {0x7F, 0x40, 0x40, 0x40, 0x40}, /* L 76 */ - {0x7F, 0x02, 0x0C, 0x02, 0x7F}, /* M 77 */ - {0x7F, 0x04, 0x08, 0x10, 0x7F}, /* N 78 */ - {0x3E, 0x41, 0x41, 0x41, 0x3E}, /* O 79 */ - {0x7F, 0x09, 0x09, 0x09, 0x06}, /* P 80 */ - {0x3E, 0x41, 0x51, 0x21, 0x5E}, /* Q 81 */ - {0x7F, 0x09, 0x19, 0x29, 0x46}, /* R 82 */ - {0x46, 0x49, 0x49, 0x49, 0x31}, /* S 83 */ - {0x01, 0x01, 0x7F, 0x01, 0x01}, /* T 84 */ - {0x3F, 0x40, 0x40, 0x40, 0x3F}, /* U 85 */ - {0x1F, 0x20, 0x40, 0x20, 0x1F}, /* V 86 */ - {0x3F, 0x40, 0x30, 0x40, 0x3F}, /* W 87 */ - {0x63, 0x14, 0x08, 0x14, 0x63}, /* X 88 */ - {0x07, 0x08, 0x70, 0x08, 0x07}, /* Y 89 */ - {0x61, 0x51, 0x49, 0x45, 0x43}, /* Z 90 */ - {0x00, 0x7F, 0x41, 0x41, 0x00}, /* [ 91 */ - {0x02, 0x04, 0x08, 0x10, 0x20}, /* \ 92 */ - {0x00, 0x41, 0x41, 0x7F, 0x00}, /* ] 93 */ - {0x04, 0x02, 0x01, 0x02, 0x04}, /* ^ 94 */ - {0x40, 0x40, 0x40, 0x40, 0x40}, /* _ 95 */ - {0x00, 0x01, 0x02, 0x04, 0x00}, /* ` 96 */ - {0x20, 0x54, 0x54, 0x54, 0x78}, /* a 97 */ - {0x7F, 0x50, 0x48, 0x48, 0x30}, /* b 98 */ - {0x38, 0x44, 0x44, 0x44, 0x20}, /* c 99 */ - {0x38, 0x44, 0x44, 0x48, 0x7F}, /* d 100 */ - {0x38, 0x54, 0x54, 0x54, 0x18}, /* e 101 */ - {0x08, 0x7E, 0x09, 0x01, 0x02}, /* f 102 */ - {0x0C, 0x52, 0x52, 0x52, 0x3E}, /* g 103 */ - {0x7F, 0x08, 0x04, 0x04, 0x78}, /* h 104 */ - {0x00, 0x44, 0x7D, 0x40, 0x00}, /* i 105 */ - {0x20, 0x40, 0x44, 0x3D, 0x00}, /* j 106 */ - {0x7F, 0x10, 0x28, 0x44, 0x00}, /* k 107 */ - {0x00, 0x41, 0x7F, 0x40, 0x00}, /* l 108 */ - {0x78, 0x04, 0x18, 0x04, 0x78}, /* m 109 */ - {0x7C, 0x08, 0x04, 0x04, 0x78}, /* n 110 */ - {0x38, 0x44, 0x44, 0x44, 0x38}, /* o 111 */ - {0x7C, 0x14, 0x14, 0x14, 0x08}, /* p 112 */ - {0x08, 0x14, 0x14, 0x18, 0x7C}, /* q 113 */ - {0x7C, 0x08, 0x04, 0x04, 0x08}, /* r 114 */ - {0x48, 0x54, 0x54, 0x54, 0x20}, /* s 115 */ - {0x04, 0x3F, 0x44, 0x40, 0x20}, /* t 116 */ - {0x3C, 0x40, 0x40, 0x20, 0x7C}, /* u 117 */ - {0x1C, 0x20, 0x40, 0x20, 0x1C}, /* v 118 */ - {0x3C, 0x40, 0x30, 0x40, 0x3C}, /* w 119 */ - {0x44, 0x28, 0x10, 0x28, 0x44}, /* x 120 */ - {0x0C, 0x50, 0x50, 0x50, 0x3C}, /* y 121 */ - {0x44, 0x64, 0x54, 0x4C, 0x44}, /* z 122 */ - {0x00, 0x08, 0x36, 0x41, 0x00}, /* { 123 */ - {0x00, 0x00, 0x7F, 0x00, 0x00}, /* | 124 */ - {0x00, 0x41, 0x36, 0x08, 0x00}, /* } 125 */ - {0x0C, 0x02, 0x0C, 0x10, 0x0C}, /* ~ 126 */ - {0x00, 0x00, 0x00, 0x00, 0x00} /* 127 */ -};
--- a/examples/adxl362_example/lcd.h Tue May 17 15:15:19 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/** - ****************************************************************************** - * @file Lcd.c - * @brief Header file for ST7565R LCD control. - * @author ADI - * @date March 2016 - * - ******************************************************************************* - * Copyright 2015(c) Analog Devices, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - Neither the name of Analog Devices, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - The use of this software may or may not infringe the patent rights - * of one or more patent holders. This license does not release you - * from the requirement that you obtain separate licenses from these - * patent holders to use this software. - * - Use of the software either in source or binary form, must be run - * on or directly connected to an Analog Devices Inc. component. - * - * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ******************************************************************************* - **/ -#ifndef LCD_H_ -#define LCD_H_ - - -/******************************************************************************/ -/***************************** Include Files **********************************/ -/******************************************************************************/ -#include <stdio.h> -#include "mbed.h" - -class Lcd -{ -public: - - const static uint8_t pui8Rec8x8[8]; - const static uint8_t pui8RecInv8x8[8]; - const static uint8_t pui8font5x7[96][5]; ///< Symbol matrix structure: Font (8x14) - - Lcd(PinName rst = D3, PinName a0 = D5, PinName bl = D8, PinName cs = D6, - PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = - SPI_SCK); - void init(void); - void display_string(uint8_t ui8row, uint8_t ui8col, int8_t *pi8str); - void display_symbol(uint8_t ui8row, uint8_t ui8col, uint8_t ui8width, - const uint8_t *pui8symbol); - void fill_pages(uint8_t ui8start, uint8_t ui8num, uint8_t ui8Data); - void set_line(uint8_t ui8line); - void set_cursor(uint8_t ui8PA, uint8_t ui8CA); - void bl_enable(); - void bl_disable(); - - void write_cmd(uint8_t cmd); - void write_data(uint8_t data); - - - typedef enum { - CMD_DISPLAY_OFF = 0xAE, - CMD_DISPLAY_ON = 0xAF, - CMD_SET_DISP_START_LINE = 0x40, - CMD_SET_PAGE = 0xB0, - CMD_SET_COLUMN_UPPER = 0x10, - CMD_SET_COLUMN_LOWER = 0x00, - CMD_SET_ADC_NORMAL = 0xA0, - CMD_SET_ADC_REVERSE = 0xA1, - CMD_SET_DISP_NORMAL = 0xA6, - CMD_SET_DISP_REVERSE = 0xA7, - CMD_SET_ALLPTS_NORMAL = 0xA4, - CMD_SET_ALLPTS_ON = 0xA5, - CMD_SET_BIAS_9 = 0xA2, - CMD_SET_BIAS_7 = 0xA3, - CMD_RMW = 0xE0, - CMD_RMW_CLEAR = 0xEE, - CMD_INTERNAL_RESET = 0xE2, - CMD_SET_COM_NORMAL = 0xC0, - CMD_SET_COM_REVERSE = 0xC8, - CMD_SET_POWER_CONTROL = 0x28, - CMD_SET_RESISTOR_RATIO = 0x20, - CMD_SET_VOLUME_FIRST = 0x81, - CMD_SET_VOLUME_SECOND = 0, - CMD_SET_STATIC_OFF = 0xAC, - CMD_SET_STATIC_ON = 0xAD, - CMD_SET_STATIC_REG = 0x0, - CMD_SET_BOOSTER_FIRST = 0xF8, - CMD_SET_BOOSTER_234 = 0, - CMD_SET_BOOSTER_5 = 1, - CMD_SET_BOOSTER_6 = 3, - CMD_NOP = 0xE3, - CMD_TEST = 0xF0, - } lcd_commands_t; - - static const uint8_t LCD_COLUMNS = 128u; - static const uint8_t LCD_PAGES = 4u; - static const uint8_t LCD_LINES = 64u; - static const uint8_t UP_X = 112; - static const uint8_t LEFT_X = 104; - static const uint8_t RIGHT_X = 120; - static const uint8_t DOWN_X = 112; - static const uint8_t CENTER_X = 112; - static const uint8_t ACC_LIMIT = 80; - static const uint8_t FONT_Y_SIZE = 8; ///< Font size for Y - static const uint8_t OFFS_ASCII = 32; ///< ASCII offset - - static const float ACC_TEMP_BIAS = 350 ; ///< Accelerometer temperature bias(in ADC codes) at 25 Deg C - static const float ACC_TEMP_SENSITIVITY = 0.065; ///< Accelerometer temperature sensitivity from datasheet (DegC per Code) - -private: - - DigitalOut rst, a0, bl, cs; - SPI lcd_spi; - - - -}; - -#endif /* LCD_H_ */
--- a/examples/adxl362_example/main.cpp Tue May 17 15:15:19 2016 +0300 +++ b/examples/adxl362_example/main.cpp Tue May 17 18:15:28 2016 +0300 @@ -44,19 +44,16 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ********************************************************************************/ + #include "mbed.h" #include "ADXL362.h" #include "lcd.h" +#include "EVAL_ADXL362_ARDZ.h" Serial pc(USBTX, USBRX); ///< Serial interface to the pc Lcd lcd; ADXL362 adxl362(D9); - -static const uint16_t INACT_VAL = 50; -static const uint16_t INACT_TIMER = 10 * 100; -static const uint16_t ACT_VAL = 50; -static const uint8_t ACT_TIMER = 100; -static const uint16_t SCAN_SENSOR_TIME = 500; +EVAL_ADXL362_ARDZ adxl362_board(lcd, adxl362); void flush_serial_buffer(void) { @@ -67,172 +64,25 @@ int main() { - uint8_t ui8s[22]; - uint8_t ui8xu = 0; - uint8_t ui8xd = 0; - uint8_t ui8yu = 0; - uint8_t ui8yd = 0; - uint8_t ui8all = 0; - lcd.init(); - adxl362.reset(); - wait_us(500); - adxl362.set_activity_threshold(ACT_VAL); - adxl362.set_activity_time(ACT_TIMER / 10); - - adxl362.set_inactivity_threshold(INACT_VAL); - adxl362.set_inactivity_time(INACT_TIMER); - adxl362.set_act_inact_ctl_reg(0x3f); -#if(ADXL_INT_SEL == INTACC_PIN_1) - adxl362.set_polling_interrupt1_pin(D2, 0x40); -#elif(ADXL_INT_SEL == INTACC_PIN_2) - adxl362.set_polling_interrupt2_pin(D2, 0x40); /* Map the awake status to INT2 pin */ -#endif - // interrupt ? - - adxl362.set_mode(ADXL362::MEASUREMENT); - - uint8_t ui8awake = 0; + adxl362_board.LCD_setup(); + adxl362_board.ADXL_setup(); /* Infinite loop */ while (1) { -#if(ADXL_INT_SEL == INTACC_PIN_1) - if (adxl362.get_int1()) { -#elif(ADXL_INT_SEL == INTACC_PIN_2) - if(adxl362.get_int2()) { -#endif - if (ui8awake == 0) { - ui8awake = 1; - - /* Set BLLCD pin - turn on LCD backlight */ - lcd.bl_enable(); - - lcd.display_string(0, 60, (int8_t *) "[mG]"); - lcd.display_string(1, 60, (int8_t *) "[mG]"); - lcd.display_string(2, 60, (int8_t *) "[mG]"); - -#if (TEMP_ADC == 1) - lcd.display_string(3, 60, (int8_t *)"[ADC]"); -#else - lcd.display_string(3, 60, (int8_t *) "[C]"); -#endif - ui8xu = 0; - ui8xd = 0; - ui8yu = 0; - ui8yd = 0; - ui8all = 0; - - lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8RecInv8x8); - lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8RecInv8x8); - lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8RecInv8x8); - lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8RecInv8x8); - lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8RecInv8x8); - } - - } else { - if (ui8awake == 1) { - ui8awake = 0; - - /* Clear BLLCD pin - turn off LCD backlight */ - lcd.bl_disable(); - - /* Clear screen */ - lcd.fill_pages(0, 4, 0x00); - } - } - - if (ui8awake == 1) { - wait_ms(100); - uint64_t acc = adxl362.scan(); - int16_t i16SensorX = static_cast<uint16_t>((acc & 0xffff000000000000) >> 48); - int16_t i16SensorY = static_cast<uint16_t>((acc & 0x0000ffff00000000) >> 32); - int16_t i16SensorZ = static_cast<uint16_t>((acc & 0x00000000ffff0000) >> 16); - int16_t i16SensorT = static_cast<uint16_t> (acc & 0x000000000000ffff); - - sprintf((char *) ui8s, "x = % 5d", i16SensorX); - lcd.display_string(0, 0, (int8_t *) ui8s); - - sprintf((char *) ui8s, "y = % 5d", i16SensorY); - lcd.display_string(1, 0, (int8_t *) ui8s); - - sprintf((char *) ui8s, "z = % 5d", i16SensorZ); - lcd.display_string(2, 0, (int8_t *) ui8s); + if(adxl362_board.ADXL_get_int()) { // ADXL362 is AWAKE ? -#if TEMP_ADC == 1 - sprintf((char *)ui8s, "t = % 5d", i16SensorT); - lcd.display_string(3, 0, (int8_t *)ui8s); -#else - float f32temp = ((float) i16SensorT + Lcd::ACC_TEMP_BIAS) - / (1 / Lcd::ACC_TEMP_SENSITIVITY); // -34.625 - sprintf((char *) ui8s, "t = % 4.1f", f32temp); - lcd.display_string(3, 0, (int8_t *) ui8s); -#endif - - if (i16SensorY > Lcd::ACC_LIMIT) { - if (ui8xu == 0) { - ui8xu = 1; - lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8Rec8x8); - } - - } else { - if (ui8xu == 1) { - ui8xu = 0; - lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8RecInv8x8); - } - } - - if (i16SensorY < -Lcd::ACC_LIMIT) { - if (ui8xd == 0) { - ui8xd = 1; - lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8Rec8x8); - } - - } else { - if (ui8xd == 1) { - ui8xd = 0; - lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8RecInv8x8); - } - } + adxl362_board.LCD_init_display(); // will only turn on if it's off + wait_ms(100); + adxl362_board.ADXL_scan_xyzt(); + adxl362_board.LCD_display_values(); + adxl362_board.LCD_display_level(); - if (i16SensorX > Lcd::ACC_LIMIT) { - if (ui8yu == 0) { - ui8yu = 1; - lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8Rec8x8); - } - - } else { - if (ui8yu == 1) { - ui8yu = 0; - lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8RecInv8x8); - } - } - - if (i16SensorX < -Lcd::ACC_LIMIT) { - if (ui8yd == 0) { - ui8yd = 1; - lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8Rec8x8); - } + } else { - } else { - if (ui8yd == 1) { - ui8yd = 0; - lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8RecInv8x8); - } - } + adxl362_board.LCD_deinit_display(); // will only turn off it it's on - if ((ui8xu == 0) && (ui8xd == 0) && (ui8yu == 0) && (ui8yd == 0)) { - if (ui8all == 0) { - ui8all = 1; - lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8Rec8x8); - } - - } else { - if (ui8all == 1) { - ui8all = 0; - lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8RecInv8x8); - } - } - } } } +}
--- a/examples/drvdiag/driver_wrapper/adxl362_diag.cpp Tue May 17 15:15:19 2016 +0300 +++ b/examples/drvdiag/driver_wrapper/adxl362_diag.cpp Tue May 17 18:15:28 2016 +0300 @@ -136,6 +136,38 @@ pc.printf("fifo scan - %x ", data); } +void ADXL362_Diag::intinit(void) +{ + + dut.reset(); + pc.printf("adxl362 reset\r\n"); + wait_ms(500); + dut.set_activity_threshold(ACT_VAL); + dut.set_activity_time(ACT_TIMER / 10); + + dut.set_inactivity_threshold(INACT_VAL); + dut.set_inactivity_time(INACT_TIMER); + dut.set_act_inact_ctl_reg(0x3f); + + pc.printf("adxl362 set activity/inactivity\r\n"); + + dut.disable_interrupt1(); + dut.set_interrupt1_pin(D2, 0x40, &rising_adxl362, &falling_adxl362); + + awake = true; + + pc.printf("adxl362 set interrupt\r\n"); + dut.enable_interrupt1(); + dut.set_mode(ADXL362::MEASUREMENT); + pc.printf("adxl362 measurement started\r\n"); +} + +void ADXL362_Diag::checkawake(void) +{ + if(awake) pc.printf("awaken"); + else pc.printf("asleep"); +} + void rising_adxl362() { awake = true;
--- a/examples/drvdiag/driver_wrapper/adxl362_diag.h Tue May 17 15:15:19 2016 +0300 +++ b/examples/drvdiag/driver_wrapper/adxl362_diag.h Tue May 17 18:15:28 2016 +0300 @@ -65,10 +65,18 @@ void fifo_setup(void); void fifo_read_u16(void); void fifo_scan(void); + void intinit(void); + void checkawake(void); private: ADXL362& dut; + + static const uint16_t INACT_VAL = 50; + static const uint16_t INACT_TIMER = 50 * 10; + static const uint16_t ACT_VAL = 50; + static const uint8_t ACT_TIMER = 100; + static const uint16_t SCAN_SENSOR_TIME = 500; }; void rising_adxl362(); void falling_adxl362();
--- a/examples/drvdiag/main.cpp Tue May 17 15:15:19 2016 +0300 +++ b/examples/drvdiag/main.cpp Tue May 17 18:15:28 2016 +0300 @@ -55,12 +55,6 @@ Serial pc(SERIAL_TX, SERIAL_RX); vector<string> cmdbuffer; -static const uint16_t INACT_VAL = 50; -static const uint16_t INACT_TIMER = 25 * 10; -static const uint16_t ACT_VAL = 50; -static const uint8_t ACT_TIMER = 100; -static const uint16_t SCAN_SENSOR_TIME = 500; - class commands { public: @@ -164,36 +158,8 @@ {"xlfset", 2, [](){adxl362diag.fifo_setup(); }}, {"xlfr16", 0, [](){adxl362diag.fifo_read_u16(); }}, {"xlfrs", 0, [](){adxl362diag.fifo_scan(); }}, - {"xlintinit",0,[](){ - adxl362.reset(); - pc.printf("adxl362 reset\r\n"); - wait_ms(500); - adxl362.set_activity_threshold(ACT_VAL); - adxl362.set_activity_time(ACT_TIMER / 10); - - adxl362.set_inactivity_threshold(INACT_VAL); - adxl362.set_inactivity_time(INACT_TIMER); - adxl362.set_act_inact_ctl_reg(0x3f); - - pc.printf("adxl362 set activity/inactivity\r\n"); - - adxl362.disable_interrupt2(); - adxl362.set_interrupt2_pin(D2,0x40,&rising_adxl362,&falling_adxl362); - extern bool awake; - awake = true; - - pc.printf("adxl362 set interrupt\r\n"); - adxl362.enable_interrupt2(); - adxl362.set_mode(ADXL362::MEASUREMENT); - pc.printf("adxl362 measurement started\r\n"); - - }}, - { - "xlawake",0,[](){ - extern bool awake; - if(awake) pc.printf("awaken"); - else pc.printf("asleep"); - } + {"xlintinit",0,[](){adxl362diag.intinit();}}, + {"xlawake",0,[](){adxl362diag.checkawake();} },
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libraries/EVAL_ADXL362_ARDZ/lcd.cpp Tue May 17 18:15:28 2016 +0300 @@ -0,0 +1,329 @@ +/** + ****************************************************************************** + * @file Lcd.c + * @brief Source file for ST7565R LCD control. + * @author ADI + * @date March 2016 + * + ******************************************************************************* + * Copyright 2015(c) Analog Devices, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * - Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * - The use of this software may or may not infringe the patent rights + * of one or more patent holders. This license does not release you + * from the requirement that you obtain separate licenses from these + * patent holders to use this software. + * - Use of the software either in source or binary form, must be run + * on or directly connected to an Analog Devices Inc. component. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************* + **/ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ +#include "../EVAL_ADXL362_ARDZ/lcd.h" + +#include "mbed.h" + + + +Lcd::Lcd(PinName rst_pin, PinName a0_pin, PinName bl_pin, + PinName cs_pin, PinName MOSI, + PinName MISO, PinName SCK) : + + rst(rst_pin), a0(a0_pin), bl(bl_pin), cs(cs_pin), lcd_spi(MOSI, MISO, SCK) +{ + rst = 1; +} + +/** + @brief Initialization of LCD screen + @return none + **/ + +void Lcd::write_cmd(uint8_t cmd) +{ + cs = 0; + a0 = 0; + lcd_spi.write(cmd); + cs = 1; +} + +void Lcd::write_data(uint8_t data) +{ + cs = 0; + a0 = 1; + lcd_spi.write(data); + cs = 1; +} + +void Lcd::bl_enable() +{ + bl = 1; +} + +void Lcd::bl_disable() +{ + bl = 0; +} + +void Lcd::init(void) +{ + + write_cmd(CMD_DISPLAY_OFF); + write_cmd(CMD_SET_BIAS_7); + write_cmd(CMD_SET_ADC_NORMAL); + write_cmd(CMD_SET_COM_REVERSE); + write_cmd((CMD_SET_RESISTOR_RATIO | 0x02)); + write_cmd(CMD_SET_VOLUME_FIRST); + write_cmd((CMD_SET_VOLUME_SECOND | 0x04)); + write_cmd((CMD_SET_POWER_CONTROL | 0x07)); + fill_pages(0, 8, 0x00); + +} + +/** + @brief Displays a string at the specified position for with 5x7 font size. + @return none + **/ +void Lcd::display_string(uint8_t ui8row, uint8_t ui8col, int8_t *pi8str) +{ + uint8_t ui8x; + uint8_t ui8i; + uint8_t ui8ch; + uint8_t ui8data; + + ui8ch = 0; + ui8x = ui8col; + + while ((pi8str[ui8ch] != 0) && (ui8col < LCD_COLUMNS)) { + set_cursor(ui8row, ui8x); /* Set cursor position */ + + for (ui8i = 0; ui8i < 5; ui8i++) { /* Symbol matrix column loop */ + ui8data = pui8font5x7[pi8str[ui8ch] - OFFS_ASCII][ui8i]; + + write_data(ui8data); + } + + ui8x += 6; /* Increase column counter with 6 pixels */ + ui8ch++; /* Increment counter */ + } + write_cmd(CMD_DISPLAY_ON); + +} + +/** + @brief Displays a symbol (8 x width) at the specified position on the LCD. + @param ui8row - row number + @param ui8col - column number + @param ui8width - symbol width + @param pui8symbol - symbol to display + @return none + **/ + +void Lcd::display_symbol(uint8_t ui8row, uint8_t ui8col, uint8_t ui8width, + const uint8_t *pui8symbol) +{ + uint8_t ui8i; + uint8_t ui8data; + + set_cursor(ui8row, ui8col); /* Set cursor position */ + for (ui8i = 0; ui8i < ui8width; ui8i++) { /* Symbol matrix column loop */ + ui8data = pui8symbol[ui8i]; + write_data(ui8data); + } + write_cmd(CMD_DISPLAY_ON); +} + +/** + @brief Fills the selected LCD pages with the data specified. + @param ui8start - start element + @param ui8num - elements numbers to fill + @param ui8Data - data to fill + @return none + **/ + +void Lcd::fill_pages(uint8_t ui8start, uint8_t ui8num, uint8_t ui8Data) +{ + + uint8_t ui8p; + uint8_t ui8c; + + for (ui8p = ui8start; ui8p < (ui8start + ui8num); ui8p++) { + set_cursor(ui8p, 0); + + for (ui8c = 0; ui8c < LCD_COLUMNS; ui8c++) { + write_data(ui8Data); + } + } + + write_cmd(CMD_DISPLAY_ON); +} + +/** + @brief Sets the start line of the LCD. + @param ui8line - line to start with + @return none + **/ + +void Lcd::set_line(uint8_t ui8line) +{ + + uint8_t ui8Cmd; + ui8Cmd = CMD_SET_DISP_START_LINE | (ui8line & 0x3F); /* Set start line */ + write_cmd(ui8Cmd); + +} + + +/** + @brief Sets the cursor position at which data will be written. + @param ui8PA - page number + @param ui8CA - column number + @return none + **/ + +void Lcd::set_cursor(uint8_t ui8PA, uint8_t ui8CA) +{ + uint8_t ui8Cmd; + + ui8Cmd = 0xB0 | (ui8PA & 0x0F); /* Set page address */ + write_cmd(ui8Cmd); + + ui8Cmd = ui8CA & 0x0F; /* Set column address LSB CA[3:0] */ + write_cmd(ui8Cmd); + + ui8Cmd = 0x10 | (ui8CA >> 4); /* Set column address MSB CA[7:4] */ + write_cmd(ui8Cmd); +} + + +const uint8_t Lcd::pui8Rec8x8[8] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; +const uint8_t Lcd::pui8RecInv8x8[8] = { + 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF +}; + +const uint8_t Lcd::pui8font5x7[96][5] = { + {0x00, 0x00, 0x00, 0x00, 0x00}, /* 32 */ + {0x00, 0x00, 0x4F, 0x00, 0x00}, /* ! 33 */ + {0x00, 0x07, 0x00, 0x07, 0x00}, /* " 34 */ + {0x14, 0x7F, 0x14, 0x7F, 0x14}, /* # 35 */ + {0x24, 0x2A, 0x7F, 0x2A, 0x12}, /* $ 36 */ + {0x23, 0x13, 0x08, 0x64, 0x62}, /* % 37 */ + {0x36, 0x49, 0x55, 0x22, 0x50}, /* & 38 */ + {0x00, 0x05, 0x03, 0x00, 0x00}, /* ' 39 */ + {0x00, 0x1C, 0x22, 0x41, 0x00}, /* ( 40 */ + {0x00, 0x41, 0x22, 0x1C, 0x00}, /* ) 41 */ + {0x14, 0x08, 0x3E, 0x08, 0x14}, /* * 42 */ + {0x08, 0x08, 0x3E, 0x08, 0x08}, /* + 43 */ + {0x00, 0x50, 0x30, 0x00, 0x00}, /* , 44 */ + {0x08, 0x08, 0x08, 0x08, 0x08}, /* - 45 */ + {0x00, 0x60, 0x60, 0x00, 0x00}, /* . 46 */ + {0x20, 0x10, 0x08, 0x04, 0x02}, /* / 47 */ + {0x3E, 0x51, 0x49, 0x45, 0x3E}, /* 0 48 */ + {0x00, 0x42, 0x7F, 0x40, 0x00}, /* 1 49 */ + {0x42, 0x61, 0x51, 0x49, 0x46}, /* 2 50 */ + {0x21, 0x41, 0x45, 0x4B, 0x31}, /* 3 51 */ + {0x18, 0x14, 0x12, 0x7F, 0x10}, /* 4 52 */ + {0x27, 0x45, 0x45, 0x45, 0x39}, /* 5 53 */ + {0x3C, 0x4A, 0x49, 0x49, 0x30}, /* 6 54 */ + {0x01, 0x71, 0x09, 0x05, 0x03}, /* 7 55 */ + {0x36, 0x49, 0x49, 0x49, 0x36}, /* 8 56 */ + {0x06, 0x49, 0x49, 0x29, 0x1E}, /* 9 57 */ + {0x36, 0x36, 0x00, 0x00, 0x00}, /* : 58 */ + {0x56, 0x36, 0x00, 0x00, 0x00}, /* ; 59 */ + {0x08, 0x14, 0x22, 0x41, 0x00}, /* < 60 */ + {0x14, 0x14, 0x14, 0x14, 0x14}, /* = 61 */ + {0x00, 0x41, 0x22, 0x14, 0x08}, /* > 62 */ + {0x02, 0x01, 0x51, 0x09, 0x06}, /* ? 63 */ + {0x30, 0x49, 0x79, 0x41, 0x3E}, /* @ 64 */ + {0x7E, 0x11, 0x11, 0x11, 0x7E}, /* A 65 */ + {0x7F, 0x49, 0x49, 0x49, 0x36}, /* B 66 */ + {0x3E, 0x41, 0x41, 0x41, 0x22}, /* C 67 */ + {0x7F, 0x41, 0x41, 0x22, 0x1C}, /* D 68 */ + {0x7F, 0x49, 0x49, 0x49, 0x41}, /* E 69 */ + {0x7F, 0x09, 0x09, 0x09, 0x01}, /* F 70 */ + {0x3E, 0x41, 0x49, 0x49, 0x7A}, /* G 71 */ + {0x7F, 0x08, 0x08, 0x08, 0x7F}, /* H 72 */ + {0x00, 0x41, 0x7F, 0x41, 0x00}, /* I 73 */ + {0x20, 0x40, 0x41, 0x3F, 0x01}, /* J 74 */ + {0x7F, 0x08, 0x14, 0x22, 0x41}, /* K 75 */ + {0x7F, 0x40, 0x40, 0x40, 0x40}, /* L 76 */ + {0x7F, 0x02, 0x0C, 0x02, 0x7F}, /* M 77 */ + {0x7F, 0x04, 0x08, 0x10, 0x7F}, /* N 78 */ + {0x3E, 0x41, 0x41, 0x41, 0x3E}, /* O 79 */ + {0x7F, 0x09, 0x09, 0x09, 0x06}, /* P 80 */ + {0x3E, 0x41, 0x51, 0x21, 0x5E}, /* Q 81 */ + {0x7F, 0x09, 0x19, 0x29, 0x46}, /* R 82 */ + {0x46, 0x49, 0x49, 0x49, 0x31}, /* S 83 */ + {0x01, 0x01, 0x7F, 0x01, 0x01}, /* T 84 */ + {0x3F, 0x40, 0x40, 0x40, 0x3F}, /* U 85 */ + {0x1F, 0x20, 0x40, 0x20, 0x1F}, /* V 86 */ + {0x3F, 0x40, 0x30, 0x40, 0x3F}, /* W 87 */ + {0x63, 0x14, 0x08, 0x14, 0x63}, /* X 88 */ + {0x07, 0x08, 0x70, 0x08, 0x07}, /* Y 89 */ + {0x61, 0x51, 0x49, 0x45, 0x43}, /* Z 90 */ + {0x00, 0x7F, 0x41, 0x41, 0x00}, /* [ 91 */ + {0x02, 0x04, 0x08, 0x10, 0x20}, /* \ 92 */ + {0x00, 0x41, 0x41, 0x7F, 0x00}, /* ] 93 */ + {0x04, 0x02, 0x01, 0x02, 0x04}, /* ^ 94 */ + {0x40, 0x40, 0x40, 0x40, 0x40}, /* _ 95 */ + {0x00, 0x01, 0x02, 0x04, 0x00}, /* ` 96 */ + {0x20, 0x54, 0x54, 0x54, 0x78}, /* a 97 */ + {0x7F, 0x50, 0x48, 0x48, 0x30}, /* b 98 */ + {0x38, 0x44, 0x44, 0x44, 0x20}, /* c 99 */ + {0x38, 0x44, 0x44, 0x48, 0x7F}, /* d 100 */ + {0x38, 0x54, 0x54, 0x54, 0x18}, /* e 101 */ + {0x08, 0x7E, 0x09, 0x01, 0x02}, /* f 102 */ + {0x0C, 0x52, 0x52, 0x52, 0x3E}, /* g 103 */ + {0x7F, 0x08, 0x04, 0x04, 0x78}, /* h 104 */ + {0x00, 0x44, 0x7D, 0x40, 0x00}, /* i 105 */ + {0x20, 0x40, 0x44, 0x3D, 0x00}, /* j 106 */ + {0x7F, 0x10, 0x28, 0x44, 0x00}, /* k 107 */ + {0x00, 0x41, 0x7F, 0x40, 0x00}, /* l 108 */ + {0x78, 0x04, 0x18, 0x04, 0x78}, /* m 109 */ + {0x7C, 0x08, 0x04, 0x04, 0x78}, /* n 110 */ + {0x38, 0x44, 0x44, 0x44, 0x38}, /* o 111 */ + {0x7C, 0x14, 0x14, 0x14, 0x08}, /* p 112 */ + {0x08, 0x14, 0x14, 0x18, 0x7C}, /* q 113 */ + {0x7C, 0x08, 0x04, 0x04, 0x08}, /* r 114 */ + {0x48, 0x54, 0x54, 0x54, 0x20}, /* s 115 */ + {0x04, 0x3F, 0x44, 0x40, 0x20}, /* t 116 */ + {0x3C, 0x40, 0x40, 0x20, 0x7C}, /* u 117 */ + {0x1C, 0x20, 0x40, 0x20, 0x1C}, /* v 118 */ + {0x3C, 0x40, 0x30, 0x40, 0x3C}, /* w 119 */ + {0x44, 0x28, 0x10, 0x28, 0x44}, /* x 120 */ + {0x0C, 0x50, 0x50, 0x50, 0x3C}, /* y 121 */ + {0x44, 0x64, 0x54, 0x4C, 0x44}, /* z 122 */ + {0x00, 0x08, 0x36, 0x41, 0x00}, /* { 123 */ + {0x00, 0x00, 0x7F, 0x00, 0x00}, /* | 124 */ + {0x00, 0x41, 0x36, 0x08, 0x00}, /* } 125 */ + {0x0C, 0x02, 0x0C, 0x10, 0x0C}, /* ~ 126 */ + {0x00, 0x00, 0x00, 0x00, 0x00} /* 127 */ +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libraries/EVAL_ADXL362_ARDZ/lcd.h Tue May 17 18:15:28 2016 +0300 @@ -0,0 +1,138 @@ +/** + ****************************************************************************** + * @file Lcd.c + * @brief Header file for ST7565R LCD control. + * @author ADI + * @date March 2016 + * + ******************************************************************************* + * Copyright 2015(c) Analog Devices, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * - Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * - The use of this software may or may not infringe the patent rights + * of one or more patent holders. This license does not release you + * from the requirement that you obtain separate licenses from these + * patent holders to use this software. + * - Use of the software either in source or binary form, must be run + * on or directly connected to an Analog Devices Inc. component. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************* + **/ +#ifndef LCD_H_ +#define LCD_H_ + + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ +#include <stdio.h> +#include "mbed.h" + +class Lcd +{ +public: + + const static uint8_t pui8Rec8x8[8]; + const static uint8_t pui8RecInv8x8[8]; + const static uint8_t pui8font5x7[96][5]; ///< Symbol matrix structure: Font (8x14) + + Lcd(PinName rst = D3, PinName a0 = D5, PinName bl = D8, PinName cs = D6, + PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = + SPI_SCK); + void init(void); + void display_string(uint8_t ui8row, uint8_t ui8col, int8_t *pi8str); + void display_symbol(uint8_t ui8row, uint8_t ui8col, uint8_t ui8width, + const uint8_t *pui8symbol); + void fill_pages(uint8_t ui8start, uint8_t ui8num, uint8_t ui8Data); + void set_line(uint8_t ui8line); + void set_cursor(uint8_t ui8PA, uint8_t ui8CA); + void bl_enable(); + void bl_disable(); + + void write_cmd(uint8_t cmd); + void write_data(uint8_t data); + + + typedef enum { + CMD_DISPLAY_OFF = 0xAE, + CMD_DISPLAY_ON = 0xAF, + CMD_SET_DISP_START_LINE = 0x40, + CMD_SET_PAGE = 0xB0, + CMD_SET_COLUMN_UPPER = 0x10, + CMD_SET_COLUMN_LOWER = 0x00, + CMD_SET_ADC_NORMAL = 0xA0, + CMD_SET_ADC_REVERSE = 0xA1, + CMD_SET_DISP_NORMAL = 0xA6, + CMD_SET_DISP_REVERSE = 0xA7, + CMD_SET_ALLPTS_NORMAL = 0xA4, + CMD_SET_ALLPTS_ON = 0xA5, + CMD_SET_BIAS_9 = 0xA2, + CMD_SET_BIAS_7 = 0xA3, + CMD_RMW = 0xE0, + CMD_RMW_CLEAR = 0xEE, + CMD_INTERNAL_RESET = 0xE2, + CMD_SET_COM_NORMAL = 0xC0, + CMD_SET_COM_REVERSE = 0xC8, + CMD_SET_POWER_CONTROL = 0x28, + CMD_SET_RESISTOR_RATIO = 0x20, + CMD_SET_VOLUME_FIRST = 0x81, + CMD_SET_VOLUME_SECOND = 0, + CMD_SET_STATIC_OFF = 0xAC, + CMD_SET_STATIC_ON = 0xAD, + CMD_SET_STATIC_REG = 0x0, + CMD_SET_BOOSTER_FIRST = 0xF8, + CMD_SET_BOOSTER_234 = 0, + CMD_SET_BOOSTER_5 = 1, + CMD_SET_BOOSTER_6 = 3, + CMD_NOP = 0xE3, + CMD_TEST = 0xF0, + } lcd_commands_t; + + static const uint8_t LCD_COLUMNS = 128u; + static const uint8_t LCD_PAGES = 4u; + static const uint8_t LCD_LINES = 64u; + static const uint8_t UP_X = 112; + static const uint8_t LEFT_X = 104; + static const uint8_t RIGHT_X = 120; + static const uint8_t DOWN_X = 112; + static const uint8_t CENTER_X = 112; + static const uint8_t ACC_LIMIT = 80; + static const uint8_t FONT_Y_SIZE = 8; ///< Font size for Y + static const uint8_t OFFS_ASCII = 32; ///< ASCII offset + + static const float ACC_TEMP_BIAS = 350 ; ///< Accelerometer temperature bias(in ADC codes) at 25 Deg C + static const float ACC_TEMP_SENSITIVITY = 0.065; ///< Accelerometer temperature sensitivity from datasheet (DegC per Code) + +private: + + DigitalOut rst, a0, bl, cs; + SPI lcd_spi; + + + +}; + +#endif /* LCD_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libraries/eval_adxl362_ardz/EVAL_ADXL362_ARDZ.cpp Tue May 17 18:15:28 2016 +0300 @@ -0,0 +1,220 @@ +/** + * @file EVAL_ADXL362_ARDZ.cpp + * @brief Source file for the EVAL-ADXL362-ARDZ board + * @author Analog Devices Inc. + * + * For support please go to: + * Github: https://github.com/analogdevicesinc/mbed-adi + * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers + * Product: www.analog.com/EVAL-ADXL362-ARDZ + * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all + + ******************************************************************************** + * Copyright 2016(c) Analog Devices, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * - Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * - The use of this software may or may not infringe the patent rights + * of one or more patent holders. This license does not release you + * from the requirement that you obtain separate licenses from these + * patent holders to use this software. + * - Use of the software either in source or binary form, must be run + * on or directly connected to an Analog Devices Inc. component. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ********************************************************************************/ + +#include "EVAL_ADXL362_ARDZ.h" + +/** + * Constructor for the EVAL_ADXL362_ARDZ + * @param _lcd reference to an LCD object + * @param _adxl362 reference to an ADXL362 object + */ +EVAL_ADXL362_ARDZ::EVAL_ADXL362_ARDZ(Lcd& _lcd, ADXL362& _adxl362) : lcd(_lcd) , adxl362(_adxl362) +{ + _x_axis_data = 0; + _y_axis_data = 0; + _z_axis_data = 0; + _t_data = 0; + _lcd_on = 0; +} + +/** + * Initial setup of the LCD + */ +void EVAL_ADXL362_ARDZ::LCD_setup() +{ + lcd.init(); +} + +/** + * Initial setup of the ADXL + */ +void EVAL_ADXL362_ARDZ::ADXL_setup() +{ + adxl362.reset(); + wait_us(500); + adxl362.set_activity_threshold(ACT_VAL); + adxl362.set_activity_time(ACT_TIMER / 10); + + adxl362.set_inactivity_threshold(INACT_VAL); + adxl362.set_inactivity_time(INACT_TIMER); + adxl362.set_act_inact_ctl_reg(0x3f); +#if(ADXL_INT_SEL == INTACC_PIN_1) + adxl362.set_polling_interrupt1_pin(D2, 0x40); +#elif(ADXL_INT_SEL == INTACC_PIN_2) + adxl362.set_polling_interrupt2_pin(D2, 0x40); /* Map the awake status to INT2 pin */ +#endif + adxl362.set_mode(ADXL362::MEASUREMENT); + _lcd_on = 0; + +} + +/** + * Method used to scan the ADXL axis data to the internal members + */ +void EVAL_ADXL362_ARDZ::ADXL_scan_xyzt() +{ + uint64_t acc = adxl362.scan(); + _x_axis_data = static_cast<uint16_t>((acc & 0xffff000000000000) >> 48); + _y_axis_data = static_cast<uint16_t>((acc & 0x0000ffff00000000) >> 32); + _z_axis_data = static_cast<uint16_t>((acc & 0x00000000ffff0000) >> 16); + _t_data = static_cast<uint16_t> (acc & 0x000000000000ffff); +} + +/** + * Gets the status of the interrupt + * @return true if interrupt is active + */ +bool EVAL_ADXL362_ARDZ::ADXL_get_int() +{ +#if(ADXL_INT_SEL == INTACC_PIN_1) + return adxl362.get_int1(); +#elif(ADXL_INT_SEL == INTACC_PIN_2) + return adxl362.get_int2(); +#endif + return false; +} + +/** + * Displays numeric values on the LCD + */ +void EVAL_ADXL362_ARDZ::LCD_display_values() +{ + uint8_t string[22]; + sprintf((char *) string, "x = % 5d", _x_axis_data); + lcd.display_string(0, 0, (int8_t *) string); + + sprintf((char *) string, "y = % 5d", _y_axis_data); + lcd.display_string(1, 0, (int8_t *) string); + + sprintf((char *) string, "z = % 5d", _z_axis_data); + lcd.display_string(2, 0, (int8_t *) string); + +#if TEMP_ADC == 1 + sprintf((char *)string, "t = % 5d", _t_data); + lcd.display_string(3, 0, (int8_t *)string); +#else + float f32temp = ((float) _t_data + Lcd::ACC_TEMP_BIAS) + / (1 / Lcd::ACC_TEMP_SENSITIVITY); // -34.625 + sprintf((char *) string, "t = % 4.1f", f32temp); + lcd.display_string(3, 0, (int8_t *) string); +#endif +} + +/** + * Displays the level meter on the LCD + */ +void EVAL_ADXL362_ARDZ::LCD_display_level() +{ + bool any_direction = false; + lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8RecInv8x8); + lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8RecInv8x8); + lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8RecInv8x8); + lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8RecInv8x8); + + if(_x_axis_data > Lcd::ACC_LIMIT) { + lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8Rec8x8); + any_direction = true; + } + if(_x_axis_data < -Lcd::ACC_LIMIT) { + lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8Rec8x8); + any_direction = true; + } + if(_y_axis_data > Lcd::ACC_LIMIT) { + lcd.display_symbol(0, Lcd::DOWN_X, 8, Lcd::pui8Rec8x8); + any_direction = true; + } + if(_y_axis_data < -Lcd::ACC_LIMIT) { + lcd.display_symbol(2, Lcd::UP_X, 8, Lcd::pui8Rec8x8); + any_direction = true; + } + if( any_direction ) lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8RecInv8x8); + else lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8Rec8x8); + +} + +/** + * Turns on the backlight and draws the static data to the LCD + */ +void EVAL_ADXL362_ARDZ::LCD_init_display() +{ + /* Set BLLCD pin - turn on LCD backlight */ + if(_lcd_on == true) return; + lcd.bl_enable(); + + lcd.display_string(0, 60, (int8_t *) "[mG]"); + lcd.display_string(1, 60, (int8_t *) "[mG]"); + lcd.display_string(2, 60, (int8_t *) "[mG]"); + +#if (TEMP_ADC == 1) + lcd.display_string(3, 60, (int8_t *)"[ADC]"); +#else + lcd.display_string(3, 60, (int8_t *) "[C]"); +#endif + + lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8RecInv8x8); + lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8RecInv8x8); + lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8RecInv8x8); + lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8RecInv8x8); + lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8RecInv8x8); + _lcd_on = true; +} + +/** + * Turns off the backlight and clears the LCD + */ +void EVAL_ADXL362_ARDZ::LCD_deinit_display() +{ + if(_lcd_on == false) return; + /* Clear BLLCD pin - turn off LCD backlight */ + lcd.bl_disable(); + + /* Clear screen */ + lcd.fill_pages(0, 4, 0x00); + _lcd_on = false; +} + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libraries/eval_adxl362_ardz/EVAL_ADXL362_ARDZ.h Tue May 17 18:15:28 2016 +0300 @@ -0,0 +1,87 @@ +/** + * @file EVAL_ADXL362_ARDZ.cpp + * @brief Header file for the EVAL-ADXL362-ARDZ board + * @author Analog Devices Inc. + * + * For support please go to: + * Github: https://github.com/analogdevicesinc/mbed-adi + * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers + * Product: www.analog.com/EVAL-ADXL362-ARDZ + * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all + + ******************************************************************************** + * Copyright 2016(c) Analog Devices, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * - Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * - The use of this software may or may not infringe the patent rights + * of one or more patent holders. This license does not release you + * from the requirement that you obtain separate licenses from these + * patent holders to use this software. + * - Use of the software either in source or binary form, must be run + * on or directly connected to an Analog Devices Inc. component. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ********************************************************************************/ + +#ifndef EVAL_ADXL362_ARDZ_H +#define EVAL_ADXL362_ARDZ_H + +#include "lcd.h" +#include "adxl362.h" + + +class EVAL_ADXL362_ARDZ +{ +public: + EVAL_ADXL362_ARDZ(Lcd& _lcd, ADXL362& _adxl362) ; + void ADXL_setup(); + void ADXL_scan_xyzt(); + bool ADXL_get_int(); + + void LCD_setup(); + void LCD_init_display(); + void LCD_deinit_display(); + void LCD_display_level(); + void LCD_display_values(); + + Lcd lcd; + ADXL362 adxl362; + +private: + + uint8_t _lcd_on; + int16_t _x_axis_data; + int16_t _y_axis_data; + int16_t _z_axis_data; + int16_t _t_data; + + static const uint16_t INACT_VAL = 50; + static const uint16_t INACT_TIMER = 100 * 10; + static const uint16_t ACT_VAL = 50; + static const uint8_t ACT_TIMER = 100; + static const uint16_t SCAN_SENSOR_TIME = 500; +}; + +#endif