Download An Introduction to BTnut Applications

Transcript
91
Appendix B
Solutions
Solution 2.1 The external memory is connected to Port A (address and data bus) and Port C (address
bus) as well as to three pins of Port G that are assigned WR*, RD* and ALE functions. A trandparent
D-type latch is used to multiplex Port A in order to save IO space at the cost of longer access times. The
BTnode rev3 further uses two pins of Port B (PB7 and PB6) to bank switch 4 banks of 60 kbytes external
memory (the processor can only make use of one bank at a time).
The LED/power latch is attached to Port C. This allows to multiplex the address bus and the latch used for
the LEDs and power/radio configuration onto Port C. It is controlled via pin PB5 (LATCH_SELECT).
Pin
PC0
PC1
PC2
PC3
PC4
PC5
PC6
PC7
Function
Blue LED
Red LED
Yellow LED
Green LED
ON_VCC_IO
ON_VCC_CC
ON_VCC_BT
RESET_BT
The first problem from this hardware setup is that the software has to keep track of the states of the latch
outputs since it is impossible to inquire the current latch state at the port outputs in software. The second
problem is that the routine for driving the latch should not be interruptible yet it has to be short so that it
does not interfere too much with other software components timing requirements.
Solution 2.2 Project setup in Eclipse follows the menu functions and is straightforward.
Solution 2.3 The indexing function is a very powerful tool within Eclipse. It is much faster than global
search and can discriminate definitions, declarations and references.
Solution 2.4 The BTnut system software supports scheduling of different patterns at the LEDs, a simple,
yet powerful user interface on embedded systems.
Solution 2.5 The Content Assist function is yet another powerful feature when using Eclipse. It allows
to quickly navigate different library functions and gives quick hints to their correct usage/syntax. Use it to
add an additional LED pattern to a simple BTnut application:
btn_hardware_init();
btn_led_init(1);
btn_led_add_pattern(BTN_LED_PATTERN_HALF,0,10,BTN_LED_INFINITE);