slcd.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief SAM Segment Liquid Crystal Display(SLCD) Controller.
  6. *
  7. * Copyright (c) 2015-2016 Atmel Corporation. All rights reserved.
  8. *
  9. * \asf_license_start
  10. *
  11. * \page License
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions are met:
  15. *
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. *
  19. * 2. Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. *
  23. * 3. The name of Atmel may not be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * 4. This software may only be redistributed and used in connection with an
  27. * Atmel microcontroller product.
  28. *
  29. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  30. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  31. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  32. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  33. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  34. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  35. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  36. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  37. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  38. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  39. * POSSIBILITY OF SUCH DAMAGE.
  40. *
  41. * \asf_license_stop
  42. *
  43. */
  44. /*
  45. * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
  46. */
  47. #ifndef SLCD_H_INCLUDED
  48. #define SLCD_H_INCLUDED
  49. /**
  50. * \defgroup asfdoc_sam0_drivers_slcd_group SAM Segment Liquid Crystal Display(SLCD) Controller
  51. *
  52. * This driver for Atmel&reg; | SMART ARM&reg;-based microcontrollers provides an interface for the configuration
  53. * and management of the device's SLCD functionality. The following
  54. * driver API modes are covered by this manual:
  55. *
  56. * - Polled APIs
  57. * - Callback APIs
  58. *
  59. *
  60. * The following peripheral is used by this module:
  61. * - Segment Liquid Crystal Display(SLCD)
  62. *
  63. * The following devices can use this module:
  64. * - Atmel | SMART SAM L22
  65. *
  66. * The outline of this documentation is as follows:
  67. * - \ref asfdoc_sam0_drivers_slcd_prerequisites
  68. * - \ref asfdoc_sam0_drivers_slcd_module_overview
  69. * - \ref asfdoc_sam0_drivers_slcd_special_considerations
  70. * - \ref asfdoc_sam0_drivers_slcd_extra_info
  71. * - \ref asfdoc_sam0_drivers_slcd_examples
  72. * - \ref asfdoc_sam0_drivers_slcd_api_overview
  73. *
  74. *
  75. * \section asfdoc_sam0_drivers_slcd_prerequisites Prerequisites
  76. *
  77. * There are no prerequisites for this module.
  78. *
  79. *
  80. * \section asfdoc_sam0_drivers_slcd_module_overview Module Overview
  81. *
  82. * \subsection asfdoc_sam0_drivers_slcd_module_overview_internal Display Overview
  83. *
  84. * A LCD display is made of several segments (pixels or complete symbols)
  85. * which can be visible or invisible. A segment has two electrodes with liquid
  86. * crystal between them. These electrodes are the common terminal (COM pin) and
  87. * the segment terminal (SEG pin). When a voltage above a threshold voltage is applied
  88. * across the liquid crystal, the segment becomes visible. The voltage must alternate,
  89. * to avoid an electrophoresis effect in the liquid crystal, which degrades the
  90. * display.
  91. *
  92. * The LCD controller is intended for monochrome passive liquid crystal display (LCD)
  93. * with up to 8 common terminals and up to 44 segment terminals. A charge pump provides
  94. * LCD display supply which can be higher than supply voltage of the device.
  95. * Each LCD pin, segment or common terminals, can be configured as general purpose I/O pins
  96. * if not driven by LCD controller.
  97. *
  98. * \section asfdoc_sam0_drivers_slcd_special_considerations Special Considerations
  99. *
  100. * \subsection asfdoc_sam0_drivers_slcd_special_considerations_io I/O Lines
  101. *
  102. * The SLCD pins (SEG and COM) are multiplexed with other peripherals. The
  103. * user application must first configure the I/O controller, to give control of
  104. * the requisite pins to the SLCD.
  105. *
  106. * \subsection asfdoc_sam0_drivers_slcd_special_considerations_power Power Management
  107. *
  108. * The SLCD will continue to operate in any sleep mode where the selected source clock
  109. * is running. The SLCD interrupts can be used to wake up the device from sleep modes.
  110. * Events connected to the event system can trigger other operations in the system
  111. * without exiting sleep modes.
  112. *
  113. * The power consumption of SLCD itself can be minimized by:
  114. * - Using the lowest acceptable frame rate (refer to the LCD glass technical
  115. * characteristics)
  116. * - Using the low-power waveform (default mode)
  117. * - Using automated modes of operation
  118. * - Configuring the lowest possible contrast value
  119. *
  120. * \section asfdoc_sam0_drivers_slcd_extra_info Extra Information
  121. *
  122. * For extra information, see \ref asfdoc_sam0_drivers_slcd_extra. This includes:
  123. * - \ref asfdoc_sam0_drivers_slcd_extra_acronyms
  124. * - \ref asfdoc_sam0_drivers_slcd_extra_dependencies
  125. * - \ref asfdoc_sam0_drivers_slcd_extra_errata
  126. * - \ref asfdoc_sam0_drivers_slcd_extra_history
  127. *
  128. * \section asfdoc_sam0_drivers_slcd_examples Examples
  129. *
  130. * For a list of examples related to this driver, see
  131. * \ref asfdoc_sam0_drivers_slcd_exqsg.
  132. *
  133. *
  134. * \section asfdoc_sam0_drivers_slcd_api_overview API Overview
  135. * @{
  136. */
  137. #include <compiler.h>
  138. #include <system.h>
  139. #ifdef __cplusplus
  140. extern "C" {
  141. #endif
  142. /**
  143. * \brief SLCD frame counter definition
  144. *
  145. * Enum SLCD frame counter definition.
  146. */
  147. enum slcd_frame_counter {
  148. /** SLCD frame counter 0 */
  149. SLCD_FRAME_COUNTER_0,
  150. /** SLCD frame counter 1 */
  151. SLCD_FRAME_COUNTER_1,
  152. /** SLCD frame counter 2 */
  153. SLCD_FRAME_COUNTER_2,
  154. };
  155. /**
  156. * \brief Waveform mode
  157. *
  158. * Enum waveform mode.
  159. */
  160. enum slcd_waveform_mode {
  161. /** Low power waveform mode */
  162. SLCD_LOW_POWER_WAVEFORM_MODE = 0,
  163. /** Standard waveform mode */
  164. SLCD_STANDARD_WAVEFORM_MODE,
  165. };
  166. /**
  167. * \brief SLCD configuration structure
  168. *
  169. * Basic configuration for SLCDC.
  170. */
  171. struct slcd_config {
  172. /** Keep SLCD enabled in standby sleep mode if true */
  173. bool run_in_standby;
  174. /** waveform mode selection */
  175. enum slcd_waveform_mode waveform_mode;
  176. /** Low resistance network duration */
  177. uint8_t low_resistance_duration;
  178. /** Enable Low resistance if true */
  179. bool enable_low_resistance;
  180. /** Bias buffer duration */
  181. uint8_t bias_buffer_duration;
  182. /** Enable bias buffer if true */
  183. bool enable_bias_buffer;
  184. };
  185. /**
  186. * \brief SLCD event enable/disable structure
  187. *
  188. * Event flags for the SLCD module. This is used to enable and
  189. * disable events via \ref slcd_enable_events() and \ref slcd_disable_events().
  190. */
  191. struct slcd_events {
  192. /** Enable event generation on frame counter 0 overflow */
  193. bool generate_event_on_fc0_overflow;
  194. /** Enable event generation on frame counter 1 overflow */
  195. bool generate_event_on_fc1_overflow;
  196. /** Enable event generation on frame counter 2 overflow */
  197. bool generate_event_on_fc2_overflow;
  198. };
  199. /**
  200. * \brief SLCD blink configuration
  201. *
  202. * SLCD blink configuration.
  203. */
  204. struct slcd_blink_config {
  205. /** Frame counter selection for blinking */
  206. enum slcd_frame_counter fc;
  207. /** All segments are allowed to blink if true, else only
  208. Selected segments are allowed to blink */
  209. bool blink_all_seg;
  210. };
  211. /**
  212. * \brief SLCD circular shift direction
  213. *
  214. * Enum SLCD circular shift direction.
  215. */
  216. enum slcd_circular_shift_dir {
  217. /** Circular shift direction is left */
  218. SLCD_CIRCULAR_SHIFT_LEFT = 0,
  219. /** Circular shift direction is right */
  220. SLCD_CIRCULAR_SHIFT_RIGHT,
  221. };
  222. /**
  223. * \brief SLCD circular shift configuration
  224. *
  225. * SLCD circular shift configuration.
  226. */
  227. struct slcd_circular_shift_config {
  228. /** Frame counter selection for circular shift */
  229. enum slcd_frame_counter fc;
  230. /** Shift direction */
  231. enum slcd_circular_shift_dir dir;
  232. /** Size of the circular shift register, MAX. size is 16 */
  233. uint8_t size;
  234. /** Circular shift register value */
  235. uint16_t data;
  236. };
  237. /**
  238. * \brief Automated char order
  239. *
  240. * Enum automated char order.
  241. */
  242. enum slcd_automated_char_order {
  243. /** Segment is starting from bottom right */
  244. SLCD_AUTOMATED_CHAR_START_FROM_BOTTOM_RIGHT = 0,
  245. /** Segment is starting from bottom left */
  246. SLCD_AUTOMATED_CHAR_START_FROM_BOTTOM_LEFT,
  247. };
  248. /**
  249. * \brief Automated char display mode
  250. *
  251. * Enum automated char display mode.
  252. */
  253. enum slcd_automated_char_mode {
  254. /** Sequential Display Mode */
  255. SLCD_AUTOMATED_CHAR_SEQ = 0,
  256. /** Scrolling Display Mode */
  257. SLCD_AUTOMATED_CHAR_SCROLL,
  258. };
  259. /**
  260. * \brief Automated char configuration
  261. *
  262. * SLCD automated char configuration.
  263. */
  264. struct slcd_automated_char_config {
  265. /** Mapping order in automated char mode */
  266. enum slcd_automated_char_order order;
  267. /** Frame counter selection for automated character mapping */
  268. enum slcd_frame_counter fc;
  269. /** Display mode */
  270. enum slcd_automated_char_mode mode;
  271. /** Define the number of SEG line per digit,
  272. it equal to number of SEG line - 1 */
  273. uint8_t seg_line_num;
  274. /** Define the index of the first segment terminal of the digit to display */
  275. uint8_t start_seg_line;
  276. /** Define the number of digit per row */
  277. uint8_t row_digit_num;
  278. /** Define the number of digit, it must be greater than 1 */
  279. uint8_t digit_num;
  280. /** Define the number of steps in scrolling mode.
  281. scrolling_step = character string length - digit_num + 1 */
  282. uint8_t scrolling_step;
  283. /** Define the number of COM line per row,
  284. it equal to number of COM line - 1 */
  285. uint8_t com_line_num;
  286. /** Segments data mask */
  287. uint32_t data_mask;
  288. };
  289. /**
  290. * \name SLCD Basic Operation Functions
  291. * @{
  292. */
  293. void slcd_get_config_defaults(struct slcd_config *config);
  294. enum status_code slcd_init(struct slcd_config *const config);
  295. void slcd_enable(void);
  296. void slcd_disable(void);
  297. bool slcd_is_enabled(void);
  298. void slcd_reset(void);
  299. enum status_code slcd_set_contrast(uint8_t contrast);
  300. /**
  301. * \brief Determines if SLCD module is currently synchronizing to the bus
  302. *
  303. * Checks to see if the underlying hardware peripheral module(s) are currently
  304. * synchronizing across multiple clock domains to the hardware bus, This
  305. * function can be used to delay further operations on a module until such time
  306. * that it is ready, to prevent blocking delays for synchronization in the
  307. * user application.
  308. *
  309. * \return Synchronization status of the underlying hardware module.
  310. *
  311. * \retval true If the module synchronization is ongoing
  312. * \retval false If the module has completed synchronization
  313. */
  314. static inline bool slcd_is_syncing(void)
  315. {
  316. if (SLCD->SYNCBUSY.reg) {
  317. return true;
  318. }
  319. return false;
  320. }
  321. /**
  322. * \brief Lock shadow memory
  323. *
  324. * It allows update of shadow display memory. If the display memory
  325. * is modified, the display remains unchanged when locked.
  326. */
  327. static inline void slcd_lock_shadow_memory(void)
  328. {
  329. SLCD->CTRLC.reg |= SLCD_CTRLC_LOCK;
  330. }
  331. /**
  332. * \brief Unlock shadow memory
  333. *
  334. * Unlock the shadow display memory.
  335. */
  336. static inline void slcd_unlock_shadow_memory(void)
  337. {
  338. SLCD->CTRLC.reg &= (SLCD_CTRLC_MASK & ( ~SLCD_CTRLC_LOCK));
  339. }
  340. /**
  341. * \brief Clear display memory
  342. *
  343. * Clears immediately the display memory.
  344. */
  345. static inline void slcd_clear_display_memory(void)
  346. {
  347. SLCD->CTRLC.reg |= SLCD_CTRLC_CLEAR;
  348. }
  349. /**
  350. * \brief Display enable
  351. *
  352. * Enable COM/SEG signal output.
  353. */
  354. static inline void slcd_enable_display(void)
  355. {
  356. SLCD->CTRLD.reg |= SLCD_CTRLD_DISPEN;
  357. while (slcd_is_syncing()) {
  358. /* Wait for synchronization */
  359. }
  360. }
  361. /**
  362. * \brief Display disable
  363. *
  364. * Disable COM/SEG signal output.
  365. */
  366. static inline void slcd_disable_display(void)
  367. {
  368. SLCD->CTRLD.reg &= (SLCD_CTRLD_MASK & ( ~SLCD_CTRLD_DISPEN));
  369. while (slcd_is_syncing()) {
  370. /* Wait for synchronization */
  371. }
  372. }
  373. /**
  374. * \brief DMA display memory update frame counter selection
  375. *
  376. * It's used to select the frame counter for DMA to update the display memory.
  377. *
  378. * \note It can be called only before the module is enabled.
  379. *
  380. * \param[in] fc Frame coungter index
  381. */
  382. static inline void slcd_dma_display_memory_update_fc_sel(enum slcd_frame_counter fc)
  383. {
  384. SLCD->CTRLA.bit.DMFCS = fc;
  385. }
  386. /** @} */
  387. /**
  388. * \name SLCD Blink Functions
  389. * @{
  390. */
  391. /**
  392. * \brief Blink mode enable
  393. *
  394. * Enable blink mode.
  395. */
  396. static inline void slcd_enable_blink(void)
  397. {
  398. SLCD->CTRLD.reg |= SLCD_CTRLD_BLINK;
  399. while (slcd_is_syncing()) {
  400. /* Wait for synchronization */
  401. }
  402. }
  403. /**
  404. * \brief Blink mode disable
  405. *
  406. * Disable blink mode.
  407. */
  408. static inline void slcd_disable_blink(void)
  409. {
  410. SLCD->CTRLD.reg &= ~SLCD_CTRLD_BLINK;
  411. while (slcd_is_syncing()) {
  412. /* Wait for synchronization */
  413. }
  414. }
  415. void slcd_blink_get_config_defaults(struct slcd_blink_config *blink_config);
  416. enum status_code slcd_blink_set_config(struct slcd_blink_config *const blink_config);
  417. void slcd_clear_blink_all_pixel(void);
  418. void slcd_clear_blink_pixel(uint8_t pix_com,uint8_t pix_seg);
  419. void slcd_set_blink_pixel(uint8_t pix_com,uint8_t pix_seg);
  420. /** @} */
  421. /**
  422. * \name SLCD Blank Functions
  423. * @{
  424. */
  425. /**
  426. * \brief Blank mode enable
  427. *
  428. * Enable blank mode.
  429. */
  430. static inline void slcd_enable_blank(void)
  431. {
  432. SLCD->CTRLD.reg |= SLCD_CTRLD_BLANK;
  433. while (slcd_is_syncing()) {
  434. /* Wait for synchronization */
  435. }
  436. }
  437. /**
  438. * \brief Blank mode disable
  439. *
  440. * Disable blank mode.
  441. */
  442. static inline void slcd_disable_blank(void)
  443. {
  444. SLCD->CTRLD.reg &= ~SLCD_CTRLD_BLANK;
  445. while (slcd_is_syncing()) {
  446. /* Wait for synchronization */
  447. }
  448. }
  449. /** @} */
  450. /**
  451. * \name SLCD Event Functions
  452. * @{
  453. */
  454. /**
  455. * \brief Enables a SLCD event output
  456. *
  457. * Enables one or more output events.
  458. *
  459. * \note Events cannot be altered while the module is enabled.
  460. *
  461. * \param[in] events Struct containing flags of events to enable
  462. */
  463. static inline void slcd_enable_events(struct slcd_events *const events)
  464. {
  465. Assert(hw);
  466. Assert(events);
  467. uint8_t event_mask = 0;
  468. if (events->generate_event_on_fc0_overflow) {
  469. event_mask |= SLCD_EVCTRL_FC0OEO;
  470. }
  471. if (events->generate_event_on_fc1_overflow) {
  472. event_mask |= SLCD_EVCTRL_FC1OEO;
  473. }
  474. if (events->generate_event_on_fc2_overflow) {
  475. event_mask |= SLCD_EVCTRL_FC2OEO;
  476. }
  477. SLCD->EVCTRL.reg |= event_mask;
  478. }
  479. /**
  480. * \brief Disables a SLCD event output
  481. *
  482. * Disables one or more SLCD events output.
  483. *
  484. * \param[in] events Struct containing flags of events to disable
  485. */
  486. static inline void slcd_disable_events(struct slcd_events *const events)
  487. {
  488. Assert(events);
  489. uint8_t event_mask = 0;
  490. if (events->generate_event_on_fc0_overflow) {
  491. event_mask |= SLCD_EVCTRL_FC0OEO;
  492. }
  493. if (events->generate_event_on_fc1_overflow) {
  494. event_mask |= SLCD_EVCTRL_FC1OEO;
  495. }
  496. if (events->generate_event_on_fc2_overflow) {
  497. event_mask |= SLCD_EVCTRL_FC2OEO;
  498. }
  499. SLCD->EVCTRL.reg &= ~event_mask;
  500. }
  501. /** @} */
  502. /**
  503. * \name SLCD Frame Counter Functions
  504. * @{
  505. */
  506. /**
  507. * \brief Frame counter configuration
  508. *
  509. * Config frame counter.
  510. *
  511. * \note Frame counter cannot be set while it is enabled.
  512. *
  513. * \param[in] fc Frame counter index
  514. * \param[in] presc_bypass_enable Bypass of the frame counter prescaler
  515. * \param[in] overflow_value Frame counter overflow value. The number of frame
  516. * before overflow is ((overflow_value+1)*8) when presc_bypass_enable=0
  517. else (overflow_value+1). The MAX. overflow value is 0x1FFFF.
  518. */
  519. static inline void slcd_set_frame_counter(enum slcd_frame_counter fc,
  520. bool presc_bypass_enable,
  521. uint16_t overflow_value)
  522. {
  523. *(&(SLCD->FC0.reg) + fc) = (presc_bypass_enable << SLCD_FC0_PB_Pos)
  524. | SLCD_FC0_OVF(overflow_value);
  525. }
  526. /**
  527. * \brief Enables a frame counter
  528. *
  529. * Enables one frame counter.
  530. *
  531. * \param[in] fc Frame counter index
  532. */
  533. static inline void slcd_enable_frame_counter(enum slcd_frame_counter fc)
  534. {
  535. switch(fc) {
  536. case SLCD_FRAME_COUNTER_0:
  537. SLCD->CTRLD.reg |= SLCD_CTRLD_FC0EN;
  538. break;
  539. case SLCD_FRAME_COUNTER_1:
  540. SLCD->CTRLD.reg |= SLCD_CTRLD_FC1EN;
  541. break;
  542. case SLCD_FRAME_COUNTER_2:
  543. SLCD->CTRLD.reg |= SLCD_CTRLD_FC2EN;
  544. break;
  545. default :
  546. break;
  547. }
  548. while (slcd_is_syncing()) {
  549. /* Wait for synchronization */
  550. }
  551. }
  552. /**
  553. * \brief Disable a frame counter.
  554. *
  555. * Disable one frame counter.
  556. *
  557. * \param[in] fc Frame counter index
  558. */
  559. static inline void slcd_disable_frame_counter(enum slcd_frame_counter fc)
  560. {
  561. switch(fc) {
  562. case SLCD_FRAME_COUNTER_0:
  563. SLCD->CTRLD.reg &= ~SLCD_CTRLD_FC0EN;
  564. break;
  565. case SLCD_FRAME_COUNTER_1:
  566. SLCD->CTRLD.reg &= ~SLCD_CTRLD_FC1EN;
  567. break;
  568. case SLCD_FRAME_COUNTER_2:
  569. SLCD->CTRLD.reg &= ~SLCD_CTRLD_FC2EN;
  570. break;
  571. default :
  572. break;
  573. }
  574. while (slcd_is_syncing()) {
  575. /* Wait for synchronization */
  576. }
  577. }
  578. /** @} */
  579. /**
  580. * \name Display Memory Functions
  581. * CPU can access display memory in direct access or in indirect access.
  582. * @{
  583. */
  584. void slcd_set_display_memory(void);
  585. void slcd_set_pixel(uint8_t pix_com, uint8_t pix_seg);
  586. void slcd_clear_pixel(uint8_t pix_com, uint8_t pix_seg);
  587. void slcd_set_seg_data(uint8_t seg_data, uint8_t byte_offset, uint8_t seg_mask);
  588. /** @} */
  589. /**
  590. * \name Character Mapping Functions
  591. * @{
  592. */
  593. void slcd_character_map_set(
  594. enum slcd_automated_char_order order,
  595. uint8_t seg_line_num);
  596. void slcd_character_write_data(uint8_t com_line_index,
  597. uint8_t seg_line_index,
  598. uint32_t seg_data,
  599. uint32_t data_mask);
  600. /**
  601. * \brief Enables automated character display
  602. *
  603. * Enables automated character display.
  604. */
  605. static inline void slcd_enable_automated_character(void)
  606. {
  607. SLCD->CTRLC.reg |= SLCD_CTRLC_ACMEN;
  608. }
  609. /**
  610. * \brief Disables automated character display
  611. *
  612. * Disables automated character display.
  613. */
  614. static inline void slcd_disable_automated_character(void)
  615. {
  616. SLCD->CTRLC.reg &= ~SLCD_CTRLC_ACMEN;
  617. }
  618. void slcd_automated_char_get_config_default(
  619. struct slcd_automated_char_config *config);
  620. enum status_code slcd_automated_char_set_config(
  621. struct slcd_automated_char_config *const config);
  622. /** @} */
  623. /**
  624. * \name Automated Bit Mapping Functions
  625. * @{
  626. */
  627. /**
  628. * \brief Enables automated bit display
  629. *
  630. * Enables automated bit display.
  631. */
  632. static inline void slcd_enable_automated_bit(void)
  633. {
  634. SLCD->CTRLC.reg |= SLCD_CTRLC_ABMEN;
  635. }
  636. /**
  637. * \brief Disables automated bit display
  638. *
  639. * Disables automated bit display.
  640. */
  641. static inline void slcd_disable_automated_bit(void)
  642. {
  643. SLCD->CTRLC.reg &= ~SLCD_CTRLC_ABMEN;
  644. }
  645. /**
  646. * \brief Sets automated bit display
  647. *
  648. * Sets automated bit display.
  649. *
  650. * \note Automated bit cannot be set while it is enabled or busy.
  651. */
  652. static inline void slcd_set_automated_bit(uint8_t size,enum slcd_frame_counter fc)
  653. {
  654. if(size > 0 && size < 0x3f) {
  655. SLCD->ABMCFG.reg = SLCD_ABMCFG_SIZE(size) | SLCD_ABMCFG_FCS(fc);
  656. }
  657. }
  658. /** @} */
  659. /**
  660. * \name Autonomous Segment Animation
  661. * @{
  662. */
  663. /**
  664. * \brief Enable SLCD circular shift mode
  665. */
  666. static inline void slcd_enable_circular_shift(void)
  667. {
  668. SLCD->CTRLD.reg |= SLCD_CTRLD_CSREN;
  669. while (slcd_is_syncing()) {
  670. /* Wait for synchronization */
  671. }
  672. }
  673. /**
  674. * \brief Disable SLCD circular shift mode
  675. */
  676. static inline void slcd_disable_circular_shift(void)
  677. {
  678. SLCD->CTRLD.reg &= ~SLCD_CTRLD_CSREN;
  679. while (slcd_is_syncing()) {
  680. /* Wait for synchronization */
  681. }
  682. }
  683. void slcd_circular_shift_get_config_defaults(
  684. struct slcd_circular_shift_config *const config);
  685. enum status_code slcd_circular_shift_set_config(
  686. struct slcd_circular_shift_config *const config);
  687. /** @} */
  688. /**
  689. * \name SLCD Status
  690. * @{
  691. */
  692. /**
  693. * \brief Checks if auto bit mapping state machine is busy
  694. *
  695. * Checks if auto bit mapping state machine is busy or not.
  696. *
  697. * \retval true Auto bit mapping state machine is busy
  698. * \retval false Auto bit mapping state machine is idle
  699. */
  700. static inline bool slcd_get_auto_bit_status(void)
  701. {
  702. return ((SLCD->STATUS.reg & SLCD_STATUS_ABMBUSY) == SLCD_STATUS_ABMBUSY);
  703. }
  704. /**
  705. * \brief Checks if auto character mapping state machine is busy
  706. *
  707. * Checks if auto character state machine is busy or not.
  708. *
  709. * \retval true Auto character mapping state machine is busy
  710. * \retval false Auto character mapping state machine is idle
  711. */
  712. static inline bool slcd_get_auto_char_status(void)
  713. {
  714. return ((SLCD->STATUS.reg & SLCD_STATUS_ACMBUSY) == SLCD_STATUS_ACMBUSY);
  715. }
  716. /**
  717. * \brief Checks if character writing function is busy
  718. *
  719. * Checksif character writing function is busy or not.
  720. *
  721. * \retval true Character writting function is busy
  722. * \retval false Character writting function is ready for use
  723. */
  724. static inline bool slcd_get_char_writing_status(void)
  725. {
  726. return ((SLCD->STATUS.reg & SLCD_STATUS_CMWRBUSY) == SLCD_STATUS_CMWRBUSY);
  727. }
  728. /**
  729. * \brief Checks VLCD and VDD33 status
  730. *
  731. * Checks VLCD and VDD33 status.
  732. *
  733. * \retval true VDD33 is greater than target VLCD
  734. * \retval false Target VLCD is greater than vdd33
  735. */
  736. static inline bool slcd_get_vlcd_vdd33_status(void)
  737. {
  738. return ((SLCD->STATUS.reg & SLCD_STATUS_VLCDS) == SLCD_STATUS_VLCDS);
  739. }
  740. /**
  741. * \brief Checks LCD charge pump status
  742. *
  743. * Checks LCD Charge Pump Status.
  744. *
  745. * \retval true LCD power charge pump is running
  746. * \retval false LCD power charge pump is stopped
  747. */
  748. static inline bool slcd_get_charge_pump_status(void)
  749. {
  750. return ((SLCD->STATUS.reg & SLCD_STATUS_PRUN) == SLCD_STATUS_PRUN);
  751. }
  752. /**
  753. * \brief Checks if VLCD is ready
  754. *
  755. * Checks if VLCD is well regulated to the target value.
  756. *
  757. * \retval true VLCD is well regulated to the target value
  758. * \retval false VLCD is not well regulated to the target value
  759. */
  760. static inline bool slcd_get_vlcd_ready_status(void)
  761. {
  762. return ((SLCD->STATUS.reg & SLCD_STATUS_VLCDR) == SLCD_STATUS_VLCDR);
  763. }
  764. /** @} */
  765. #ifdef __cplusplus
  766. }
  767. #endif
  768. /** @} */
  769. /**
  770. * \page asfdoc_sam0_drivers_slcd_extra Extra Information for SLCD
  771. *
  772. * \section asfdoc_sam0_drivers_slcd_extra_acronyms Acronyms
  773. * Below is a table listing the acronyms used in this module, along with their
  774. * intended meanings.
  775. *
  776. * <table>
  777. * <tr>
  778. * <th>Acronym</th>
  779. * <th>Definition</th>
  780. * </tr>
  781. * <tr>
  782. * <td>SLCD</td>
  783. * <td>Segment Liquid Crystal Display</td>
  784. * </tr>
  785. * <tr>
  786. * <td>COM</td>
  787. * <td>Common, denotes how many segments are connected to a segment terminal</td>
  788. * </tr>
  789. * <tr>
  790. * <td>SEG</td>
  791. * <td>Segment, the least viewing element (pixel) which can be on or off</td>
  792. * </tr>
  793. * <tr>
  794. * <td>Duty</td>
  795. * <td> 1/(Number of common terminals on an actual LCD display)</td>
  796. * </tr>
  797. * <tr>
  798. * <td>Bias</td>
  799. * <td>1/(Number of voltage levels used driving a LCD display -1)</td>
  800. * </tr>
  801. * <tr>
  802. * <td>Frame Rate</td>
  803. * <td>Number of times the LCD segments are energized per second</td>
  804. * </tr>
  805. * </table>
  806. *
  807. *
  808. * \section asfdoc_sam0_drivers_slcd_extra_dependencies Dependencies
  809. * This driver has the following dependencies:
  810. *
  811. * - None
  812. *
  813. *
  814. * \section asfdoc_sam0_drivers_slcd_extra_errata Errata
  815. * There are no errata related to this driver.
  816. *
  817. *
  818. * \section asfdoc_sam0_drivers_slcd_extra_history Module History
  819. * An overview of the module history is presented in the table below, with
  820. * details on the enhancements and fixes made to the module since its first
  821. * release. The current version of this corresponds to the newest version in
  822. * the table.
  823. *
  824. * <table>
  825. * <tr>
  826. * <th>Changelog</th>
  827. * </tr>
  828. * <tr>
  829. * <td>Initial release</td>
  830. * </tr>
  831. * </table>
  832. */
  833. /**
  834. * \page asfdoc_sam0_drivers_slcd_exqsg Examples for SLCD
  835. *
  836. * This is a list of the available Quick Start Guides (QSGs) and example
  837. * applications for \ref asfdoc_sam0_drivers_slcd_group. QSGs are simple examples with
  838. * step-by-step instructions to configure and use this driver in a selection of
  839. * use cases. Note that a QSG can be compiled as a standalone application or be
  840. * added to the user application.
  841. *
  842. * - \subpage asfdoc_sam0_slcd_basic_use_case
  843. *
  844. * \page asfdoc_sam0_drivers_slcd_document_revision_history Document Revision History
  845. *
  846. * <table>
  847. * <tr>
  848. * <th>Doc. rev.</th>
  849. * <th>Date</th>
  850. * <th>Comments</th>
  851. * </tr>
  852. * <tr>
  853. * <td>42605A</td>
  854. * <td>12/2015</td>
  855. * <td>Initial release</td>
  856. * </tr>
  857. * </table>
  858. *
  859. */
  860. #endif /* SLCD_H_INCLUDED */