Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ARM Drivers
- ===========
- H/W setup
- ---------
- The board is designed with an ST 401 arm microcontroller with the following peripherals:
- * Flash memory (**W25Q128**) connected via SPI to SPI 3 interface
- * TFT LCD display (Sharp **LS010B7DH01**) connected via SPI to SPI 3 interface
- * Accelerometer (ST **LIS2TE**) connected via SPI to SPI 3 interface
- * Dual-mode Bluetooth module (**TI CC2564**) connected via UART
- The Bluetooth runs using the Bluetopia Stack and needs to be setup with the above configuration.
- The program logic has been written and requires the following drivers to be implemented on the host setup
- Memory
- ------
- basic memory methods
- Signatures:
- * `int Memory_erase(UInt32 address)`
- * `int Memory_write(UInt32 address,UInt16 size,UInt8 *buffer)`
- * `int Memory_read(UInt32 address,UInt16 size,UInt8 *buffer)`
- ### Memory_erase
- erases a 64k segment of the flash
- * `address` - 32bit address to the begining of a 64k segement to erase
- Returns `0` on success
- ### Memory_write
- Writes a bulk of data to the flash at the specified address (max 256 bytes)
- * `address` - 32bit address to start writing to
- * `size` - number of bytes to write (**max 256**)
- * `buffer` - pointer to data buffer containing the data
- Returns `0` on success
- ### Memory_read
- Reads a set of bytes from the given address in the flash to a buffer
- * `address` - 32bit address to start reading from
- * `size` - 16bit value specifying the number of bytes to read
- * `buffer` - pointer to buffer to fill
- Returns `0` on success
- Display
- -------
- LCD control methods
- Signatures:
- * `int Screen_toggle(BOOL on)`
- * `int Screen_showFrame(UInt32 address,UInt16 size,ScreenFrameCallback_t callback)`
- Callback Signatures:
- * `typedef void (*ScreenFrameCallback_t)(UInt32 address,Int16 time)`
- ### Screen_toggle
- Toggles the display on/off
- * `on` - `TRUE` if the screen should be switched on, `FALSE` if it is to be switched off
- Returns `0` on success
- ### Screen_showFrame
- Displays a frame located at the given address on the flash to the screen
- *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
- * `address` - 32bit address where the frame (including LCD commands) is located on the flash
- * `size` - number of bytes to be sent to the screen
- * `callback` - pointer to callback method that will be called when the frame has been fully copied to the screen
- * the callback will recieve the following arguments:
- * `address` - the 32bit address the frame was displayed from
- * `time` - time in ms from when `Screen_showFrame` was called until this callback was called
- The method return `0` if the transfer was succesfully started.
- Power
- -----
- Methods should be written to track the battery state and disconnect the battery when it reaches below a critical level
- 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
- 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)
- Power mode settings
- Constants:
- * `POWER_MODE_BATTERY_DISCHARGE` - No AC connected, battery power only
- * `POWER_MODE_AC_CONNECTED` - the AC adapter is connected and power is supplied from it
- * `POWER_MODE_AC_CHARGE` - (in combination with A/C connected) thebattery is charging from the AC
- Method Signatures:
- * `UInt8 Power_getChargeLevel()`
- * `UInt8 Power_getMode()`
- ### Power_getChargeLevel
- Returns the last measured power charge of the battery in percent (0-100)
- ### Power_getMode
- returns the current power mode (discharge/ac connected/ac charging)
- returns a bitwise mask of the `POWER_MODE*` constants
- Accelerometer
- -------------
- ### Sleep mode
- The device should enter sleep mode when no movement has occured for a period of time and resumed when movement is detected
- The accelerometer should be tracked to understand when there has been no movement over a predefined period of time
- 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).
- Once the device has gone into *sleep mode* any movement detected by the accelerometer should wake the device.
- 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).
- 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.
- ### Taps
- When the accelerometer detects a `Tap` or `Double tap` an event should be raised so the app logic can handle it and respond
- with feedback to the user
- Front Light
- -----------
- The front light should be controlled with a specified color and intesity
- Signatures:
- * `int FrontLight_adjust(UInt8 intensity,UInt16 color)`
- ### FrontLight_adjust
- Adjusts the front light color and intensity
- * `intensity` - specifies the power level to drive the LED's with
- * `color` - 16bit value specifying the values of the white/red/green/blue leds
- * each led is specied by a nible in the number 0xWRGBA So:
- * Full white = `0xF000`
- * Full red = `0x0F00`
- * Full yellow = `0x0FF0`
- * Bright Blue = `0xA00F`
- Events
- ------
- Events are managed in a pub/sub method by the events hub written by the app logic.
- To fire an event, all that is needed is to call `void event_fire(int type,void *data)`
- 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