nrf6350.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /**
  2. * Copyright (c) 2012 - 2020, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #ifndef NRF6350_H_
  41. #define NRF6350_H_
  42. #include <stdbool.h>
  43. #include <stdint.h>
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. #define LCD_LLEN 16 //!< LCD Line length
  48. #define JS_BUTTON_NONE 0x00 //!< Joystick not touched
  49. #define JS_BUTTON_LEFT 0x01 //!< joystick pulled left
  50. #define JS_BUTTON_PUSH 0x02 //!< joystick pushed
  51. #define JS_BUTTON_DOWN 0x04 //!< joystick pulled down
  52. #define JS_BUTTON_UP 0x08 //!< joystick pulled up
  53. #define JS_BUTTON_RIGHT 0x10 //!< joystick pulled right
  54. #define LCD_UPPER_LINE 0x00 //!< LCD upper line
  55. #define LCD_LOWER_LINE 0x40 //!< LCD lower line
  56. #define LCD_CONTRAST_LOW 0x00 //!< LCD Low contrast
  57. #define LCD_CONTRAST_MEDIUM 0x02 //!< LCD Medium contrast
  58. #define LCD_CONTRAST_HIGH 0x08 //!< LCD High contrast
  59. /**
  60. * @brief Function for initializing the LCD display prior to writing.
  61. * @return
  62. * @retval true Operation succeeded
  63. * @retval false Operation failed
  64. */
  65. bool nrf6350_lcd_init(void);
  66. /**
  67. * @brief Function for writing a text string on the LCD-display.
  68. *
  69. * @param p_text A pointer to the text string to be written
  70. * @param size Size of the text string to be written
  71. * @param line The line the text should be written to
  72. * @param pos The start position of the text on the line
  73. * @return
  74. * @retval true Write succeeded
  75. * @retval false Write failed
  76. */
  77. bool nrf6350_lcd_write_string(const char *p_text, uint8_t size, uint8_t line, uint8_t pos);
  78. /**
  79. * @brief Function for clearing the contents of the LCD-display.
  80. *
  81. * @return
  82. * @retval true Operation succeeded
  83. * @retval false Operation failed
  84. */
  85. bool nrf6350_lcd_clear(void);
  86. /**
  87. * @brief Function for adjusting the contrast of the LCD-display, select between
  88. * LCD_CONTRAST_LOW, LCD_CONTRAST_MEDIUM and LCD_CONTRAST_HIGH.
  89. *
  90. * @param contrast The desired contrast of the lcd display
  91. * @return
  92. * @retval true Operation succeeded
  93. * @retval false Operation failed
  94. */
  95. bool nrf6350_lcd_set_contrast(uint8_t contrast);
  96. /**
  97. * @brief Function for turning ON the LCD-display.
  98. *
  99. * @return
  100. * @retval true Operation succeeded
  101. * @retval false Operation failed
  102. */
  103. bool nrf6350_lcd_on(void);
  104. /**
  105. * @brief Function for turning OFF the LCD-display.
  106. *
  107. * @return
  108. * @retval true Operation succeeded
  109. * @retval false Operation failed
  110. */
  111. bool nrf6350_lcd_off(void);
  112. /**
  113. * @brief Function for getting the position of the joystick.
  114. *
  115. * @param val pointer to a 2 byte array where the X,Y position is stored
  116. * @return
  117. * @retval true Operation succeeded
  118. * @retval false Operation failed
  119. */
  120. bool nrf6350_js_get_value(int8_t *val);
  121. /**
  122. * @brief Function for getting the status of the joystick.
  123. *
  124. * @param js_state pointer to a uint8_t that receives the status of the joystick
  125. * @return
  126. * @retval true Operation succeeded
  127. * @retval false Operation failed
  128. */
  129. bool nrf6350_js_get_status(uint8_t *js_state);
  130. /** @brief Function for transferring data over TWI bus. Used the first time you want to communicate nRF6350 to bypass a fail.
  131. */
  132. bool nrf6350_lcd_wake_up(void);
  133. #ifdef __cplusplus
  134. }
  135. #endif
  136. #endif // NRF6350_H_
  137. /** @} */