Button/LED Peripheral Core with Wishbone Interface

Features

  • Register based button and LED control for the B/LED Wing
  • Supports simultaneous programming of all 4 LEDs (via LEDLATCH register), or per LED control (via LEDON and LEDOFF registers).
  • Shows real time status of all 4 buttons, with interrupt control.

Register Interface

The Button/LED Controller Peripheral interface consists of 5 user accessible registers:

Address
Register Name Width Description
BASE+00 LEDLATCH 16 LED control and real time status
BASE+02 LEDON 16 Set LED ON
BASE+04 LEDOFF 16 Set LED OFF
BASE+06 BTNSTATUS 16 Real time status of all buttons
BASE+08 BTNINTCONTROL 16 Interrupt control and status of all buttons

Base address is defined by the bus controller in higher hierarchy of HDL code. All these registers are 16-bit wide. For 8-bit access, above registers are broken into two 8-bit registers each with suffixes 'L' and 'H' for low and high bytes respectively.

LED Latch

The LED latch register controls each of the LEDs (one bit per LED). It can also be read to get the status of the LEDs. If a bit is '1', the LED is on, else it is off. One or more of the bits are also updated by writing to the LEDON and LEDOFF registers.

Bit Symbol Access Description
0 LEDLATCH1 R/W LED 1 Status
1 LEDLATCH2 R/W LED 2 Status
2 LEDLATCH3 R/W LED 3 Status
3 LEDLATCH4 R/W LED 4 Status
15~4 Reserved

LED On

This write-only register switches ON one or more LEDs independently. The bits where '1's are written will switch on the corresponding LEDs. A '0' has no effect. The corresponding bits in the LEDLATCH register are then updated.

Bit Symbol Access Description
0 LEDON1 W Turn on LED 1
1 LEDON2 W Turn on LED 2
2 LEDON3 W Turn on LED 3
3 LEDON4 W Turn on LED 4
15~4 Reserved

LED Off

This write-only register switches OFF one or more LEDs independently. The bits where '1's are written will switch off the corresponding LEDs. A '0' has no effect. The corresponding bits in the LEDLATCH register are then updated.

Bit Symbol Access Description
0 LEDOFF1 W Turn off LED 1
1 LEDOFF2 W Turn off LED 2
2 LEDOFF3 W Turn off LED 3
3 LEDOFF4 W Turn off LED 4
15~4 Reserved

Buttons Status

This read-only register shows the real time status of the buttons.

Bit Symbol Access Description
0 BUTTON1 R Button 1 status
1 BUTTON2 R Button 2 status
2 BUTTON3 R Button 3 status
3 BUTTON4 R Button 4 status
15~4 Reserved

Buttons Interrupt control

This register controls the interrupts after button press events. SW needs to clear bits 1 to 4 after servicing the interrupt.

Bit Symbol Access Description
0 BTNIE R/W Button Interrupt Enable
1 BTNINT1 R/W Button 1 Interrupt Status
2 BTNINT2 R/W Button 2 Interrupt Status
3 BTNINT3 R/W Button 3 Interrupt Status
4 BTNINT4 R/W Button 4 Interrupt Status
15~5 Reserved

Resources

 

 

License

This code is released under the Creative Commons Attribution license. Please give attribution to the original author and Gadget Factory (www.gadgetfactory.net).

This work is licensed under a Creative Commons Attribution 3.0 License.

  

Share |