Firmware functions
Below is a description of the various firmware sub-
routines.
WM430_System.c –
mouse main program featuring
nRF2402 transmitter (wm430_transmitter.c), ADNS-
3530 sensor (MSP430_AVAGO_ADNS-3530.c), buttons
(wm430_button.c) and battery indicator (MSP430_
battery_indicator.c) programs.
wm430_transmitter.c –
this program features RF protocol
implementation.
MSP430_AVAGO_ADNS-3530.c –
this program is for
MSP430 device driver functions to communicate with
Avago ADNS-3530 optical sensor.
wm430_button.c –
this program is for button related
functions
MSP430_battery_indicator.c –
this program is for battery
indicator functions
wm430_wheel.c –
this program features the logic imple-
mentation for button (ZA & ZB) scrolling movements.
WM430_sys_intiInternal ( ) –
this function is for internal
system initialization. It involves GPIO functions, timer
A operations and DCO calibration initializations. For
hardware SPI pins configuration, MOSI is connected to
P3.1, MISO is connected to P3.2, SCL is connected to
P3.3, NCS is connected to P1.3, MOTION is connect to
P2.2 and SHTDWN is connected to P2.3. Whereas for the
NORDIC nRF2402 transmitter, CONTROL 1 is connected
to CE, CONTROL 2 is connected to PWR_UP, CONTROL 3
is connected to CS, SCL is connected to CLK and MOSI is
connected to DIN.
WM430_BATTERY_init ( ) –
this function is for battery
indicator initialization whereby a sample is taken from
P2.0 of MSP430F1222 with reference to 2.5V. The ADC10
internal oscillator times sample selected is 16.
WM430_BUTONS_int ( ) –
this function is used to initial-
ize the button module and GPIO functions configura-
tions. The left, right, scroll ZA and scroll ZB buttons are
connected to P1.0, P1.2, P2.5 and P2.1 of MPS430F1222
respectively.
WM430_TX_int ( ) –
this function initializes the transmit-
ter software module.
WM430_SYS_initDevices ( ) –
it is used to initial-
ize external devices such as ADNS-3530 and NORDIC
nRF2402 transmitter. The product and inverse product IDs
of the optical sensor are checked in this function.
WM430_SYS_generateNewID ( ) –
this function is re-
sponsible for new ID generation.
_EINT ( ) –
it enables global interrupts
WM430_SYS_battery_sequence ( ) –
this function
defines the battery indicator sequence. The led will blink
when the battery level is low or medium level and it will
not blink when the battery level is full.
WM430_BUTTONS_processLeft ( ) –
it is used to process
left button when it is pressed
WM430_BUTTONS_processRight ( ) –
this function is to
process the right button when it is pressed.
WM430_BUTTONS_processZAZBPressed
processes the scrolling button(s) when it is pressed con-
tinuously.
(
)
–
it
WM430_WHEEL_resetActiveTimeout ( ) –
this function
is for resetting the time out counter to keep scroll
button detection enabled. It will extend ACTIVE mode to
maximum time if the MCU is already awake.
WM430_BUTTONS_processZA ( ) –
it is used to process
scrolling button ZA when it is pressed.
WM430_BUTTONS_processZB ( ) –
it processes scrolling
button ZA when it is pressed.
WM430_WHEEL_decodeZState ( ) –
this function is
responsible for updating the scrolling button ZA and
button ZB directions.
WM430_TX_sendDataPacket ( ) –
this function receives
four parameters namely button, X displacement, Y dis-
placement and Z displacement data. Then they are trans-
mitted to the NORDIC nRF2401AG receiver.
WM430_SYS_clearWatchDog ( ) –
this function is used to
reset the watch dog timer to prevent the hardware reset.
WM430_BUTTONS_configureInterrupts ( ) –
it deter-
mines the state of the buttons and configures each
button interrupt for rising or falling edge detection.
WM430_BUTTONS_checkRelease ( ) –
this function
is used to check whether any of the buttons have been
released.
WM430_SYS_enableSensorINT ( ) –
this function is used
for enabling the sensor motion interrupt.
WM430_SYS_disableSensorInt ( ) –
it is used to disable
the sensor motion interrupt.
MSP430_NORDIC_nRF2402_powerDown ( ) –
this
function is called to power down the NORDIC nRF2402
device.
MSP430_NORDIC_nRF2402_powerUp ( ) –
it is called to
power up the NORDIC nRF2402 device.
The firmware block diagram is shown in Figure 4.