Advertisement
Guest User

Untitled

a guest
May 28th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.83 KB | None | 0 0
  1. ARM Drivers
  2. ===========
  3.  
  4. H/W setup
  5. ---------
  6. The board is designed with an ST 401 arm microcontroller with the following peripherals:
  7. * Flash memory (**W25Q128**) connected via SPI to SPI 3 interface
  8. * TFT LCD display (Sharp **LS010B7DH01**) connected via SPI to SPI 3 interface
  9. * Accelerometer (ST **LIS2TE**) connected via SPI to SPI 3 interface
  10. * Dual-mode Bluetooth module (**TI CC2564**) connected via UART
  11.  
  12. The Bluetooth runs using the Bluetopia Stack and needs to be setup with the above configuration.
  13.  
  14. The program logic has been written and requires the following drivers to be implemented on the host setup
  15.  
  16.  
  17. Memory
  18. ------
  19. basic memory methods
  20.  
  21. Signatures:
  22.  
  23. * `int Memory_erase(UInt32 address)`
  24. * `int Memory_write(UInt32 address,UInt16 size,UInt8 *buffer)`
  25. * `int Memory_read(UInt32 address,UInt16 size,UInt8 *buffer)`
  26.  
  27. ### Memory_erase
  28. erases a 64k segment of the flash
  29. * `address` - 32bit address to the begining of a 64k segement to erase
  30. Returns `0` on success
  31.  
  32. ### Memory_write
  33. Writes a bulk of data to the flash at the specified address (max 256 bytes)
  34. * `address` - 32bit address to start writing to
  35. * `size` - number of bytes to write (**max 256**)
  36. * `buffer` - pointer to data buffer containing the data
  37. Returns `0` on success
  38.  
  39. ### Memory_read
  40. Reads a set of bytes from the given address in the flash to a buffer
  41. * `address` - 32bit address to start reading from
  42. * `size` - 16bit value specifying the number of bytes to read
  43. * `buffer` - pointer to buffer to fill
  44. Returns `0` on success
  45.  
  46. Display
  47. -------
  48. LCD control methods
  49.  
  50. Signatures:
  51. * `int Screen_toggle(BOOL on)`
  52. * `int Screen_showFrame(UInt32 address,UInt16 size,ScreenFrameCallback_t callback)`
  53.  
  54. Callback Signatures:
  55. * `typedef void (*ScreenFrameCallback_t)(UInt32 address,Int16 time)`
  56.  
  57. ### Screen_toggle
  58. Toggles the display on/off
  59. * `on` - `TRUE` if the screen should be switched on, `FALSE` if it is to be switched off
  60. Returns `0` on success
  61.  
  62. ### Screen_showFrame
  63. Displays a frame located at the given address on the flash to the screen
  64. *Note:* the transfer is done using direct DMA between the two peripherials and the method returns when the transfer begins, and executes the callback when the DMA process completes
  65. * `address` - 32bit address where the frame (including LCD commands) is located on the flash
  66. * `size` - number of bytes to be sent to the screen
  67. * `callback` - pointer to callback method that will be called when the frame has been fully copied to the screen
  68. * the callback will recieve the following arguments:
  69. * `address` - the 32bit address the frame was displayed from
  70. * `time` - time in ms from when `Screen_showFrame` was called until this callback was called
  71. The method return `0` if the transfer was succesfully started.
  72.  
  73. Power
  74. -----
  75. Methods should be written to track the battery state and disconnect the battery when it reaches below a critical level
  76. A timer should be set to test the current battery charge level, and store it so it can be returned when the `Power_getChargeLevel` method is called
  77.  
  78. Also, an `event` should be raised when the battery powe goes under a preset threshold so the default animation routine can be halted and a low power frame can be displayed (handled by the app logic, all that is needed from the driver is to fire the event)
  79.  
  80. Power mode settings
  81.  
  82. Constants:
  83. * `POWER_MODE_BATTERY_DISCHARGE` - No AC connected, battery power only
  84. * `POWER_MODE_AC_CONNECTED` - the AC adapter is connected and power is supplied from it
  85. * `POWER_MODE_AC_CHARGE` - (in combination with A/C connected) thebattery is charging from the AC
  86.  
  87. Method Signatures:
  88. * `UInt8 Power_getChargeLevel()`
  89. * `UInt8 Power_getMode()`
  90.  
  91. ### Power_getChargeLevel
  92. Returns the last measured power charge of the battery in percent (0-100)
  93.  
  94. ### Power_getMode
  95. returns the current power mode (discharge/ac connected/ac charging)
  96. returns a bitwise mask of the `POWER_MODE*` constants
  97.  
  98. Accelerometer
  99. -------------
  100. ### Sleep mode
  101.  
  102. The device should enter sleep mode when no movement has occured for a period of time and resumed when movement is detected
  103.  
  104. The accelerometer should be tracked to understand when there has been no movement over a predefined period of time
  105. When this has occured an `event` should be raised so the device can go into *sleep mode* (handled by the app logic, all that is needed from the driver is to fire the event).
  106. Once the device has gone into *sleep mode* any movement detected by the accelerometer should wake the device.
  107. When movement has occured in this state, an `event` should be raised so the device can resume playing its animation (handled by the app logic, all that is needed from the driver is to fire the event).
  108.  
  109. I suggest implementing a simple sliding window timer mechanism, where a timer is set up for a predefined time and reset everytime movement is detected. When the timer fires, it is assumed no movement was detected during the timer interval.
  110.  
  111. ### Taps
  112. When the accelerometer detects a `Tap` or `Double tap` an event should be raised so the app logic can handle it and respond
  113. with feedback to the user
  114.  
  115. Front Light
  116. -----------
  117. The front light should be controlled with a specified color and intesity
  118.  
  119. Signatures:
  120. * `int FrontLight_adjust(UInt8 intensity,UInt16 color)`
  121.  
  122. ### FrontLight_adjust
  123. Adjusts the front light color and intensity
  124. * `intensity` - specifies the power level to drive the LED's with
  125. * `color` - 16bit value specifying the values of the white/red/green/blue leds
  126. * each led is specied by a nible in the number 0xWRGBA So:
  127. * Full white = `0xF000`
  128. * Full red = `0x0F00`
  129. * Full yellow = `0x0FF0`
  130. * Bright Blue = `0xA00F`
  131.  
  132. Events
  133. ------
  134. Events are managed in a pub/sub method by the events hub written by the app logic.
  135. To fire an event, all that is needed is to call `void event_fire(int type,void *data)`
  136. sending it the type of event to fire (managed be executor) and a pointer to a custom struct containing any extra event data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement