Lab: GPIO

Objective
  • Manipulate microcontroller's registers in order to access and control physical pins
  • Use implemented driver to sense input signals and control LEDs
  • Use FreeRTOS binary semaphore to signal between tasks

Part 0: Basic task structure to blink an LED

In this portion of the lab, you will design a basic task structure, and directly manipulate the microcontroller register to blink an on-board LED. You will not need to implement a full GPIO driver for this part. Instead, directly manipulate registers from LPC40xx.h

 


Part 1: GPIO Driver

Use the following template to implement a GPIO driver composed of:

  • Header file
  • Source file

Implement ALL of the following methods. All methods must work as expected as described in the comments above their method name. Note that you shall not use or reference to the existing gpio.h or gpio.c and instead, you should build your own gpio_lab.h and gpio_lab.c as shown below.

Extra Credit
Design your driver to be able to handle multiple ports (port 1 and port 2) within a single gpio driver file
Do this only after you have completed all of the lab

 


Part 2. Use GPIO driver to blink two LEDs in two tasks

This portion of the lab will help you understand the task_parameter that can be passed into tasks when they start to run. You will better understand that each task has its own context, and its own copies of variables even though we will use the same function for two tasks.

 


Part 3: LED and Switch
  • Design an LED task and a Switch task
  • Interface the switch and LED task with a Binary Semaphore
  • Deprecated requirements:
    • For this final portion of the lab, you will interface an external LED and an external switch
    • Do not use the on-board LEDs for the final demonstration of the lab

    • Hint: You can make it work with on-board LED and a switch before you go to the external LED and an external switch
Requirements:
  • Do not use any pre-existing code or library available in your sample project (such as gpio.h)
  • You should use memory mapped peripherals that you can access through LPC40xx.h

Upload only relevant .c files into canvas. A good example is: main.c, lab_gpio_0.c. See Canvas for rubric and grade breakdown.

Extra Credit
Add a flashy easter egg feature to your assignment, with your new found LED and switch powers! The extra credit is subject to the instructor's, ISA's and TA's discretion about what is worth the extra credit. Be creative. Ex: Flash board LEDs from left to right or left to right when button pressed, and preferably do this using a loop rather than hard-coded sequence

 

  
Back to top