"led.h": "c",
"stm32f730xx.h": "c",
"keyboard.h": "c",
- "gpio_helper.h": "c"
+ "gpio_helper.h": "c",
+ "stdint.h": "c"
}
}
\ No newline at end of file
- [ ] adapt ms_wait() and us_wait()
- [ ] Screen interface
- [ ] UI toolkit
+ - [ ] set pixel
- [ ] text display
- [ ] fill rect
- - [ ] image display
\ No newline at end of file
+ - [ ] image display
+- [ ] File system
+ - [ ] Plan what to do
\ No newline at end of file
uint8_t GPIOD_state = 0;
uint8_t GPIOE_state = 0;
+/* Set a pin High (true) or Low (false) ie:
+ set_output_pin(GPIO_B, 2, true);
+ this sets the pin B2 to high */
void set_output_pin(uint8_t gpio_x, uint8_t pin, bool state){
switch (gpio_x)
{
}
}
+/* Read the value of an input pin, it returns High (true) or Low (false) ie:
+ bool state = read_input_pin(GPIO_C, 3);
+ This stores the state of the pin C3 */
bool read_input_pin(uint8_t gpio_x, uint8_t pin){
// Invert the IDR register since '0' means 'pressed'.
uint8_t idr_val = 0;
return idr_val & (1 << pin);
}
+/* Enable the specified GPIO */
void enable_gpio_x_rcc(uint8_t gpio_x){
switch (gpio_x)
{
#define GPIO_D 3
#define GPIO_E 4
+/* Set a pin High (true) or Low (false) ie:
+ set_output_pin(GPIO_B, 2, true);
+ this sets the pin B2 to high */
void set_output_pin(uint8_t gpio_x, uint8_t pin, bool state);
+
+/* Read the value of an input pin, it returns High (true) or Low (false) ie:
+ bool state = read_input_pin(GPIO_C, 3);
+ This stores the state of the pin C3 */
bool read_input_pin(uint8_t gpio_x, uint8_t pin);
+
+/* Enable the specified GPIO */
void enable_gpio_x_rcc(uint8_t gpio_x);
#endif
\ No newline at end of file
const uint8_t number_of_columns = 6;
const char row_list[9] = {'B', 'A', 'C', 'D', 'E', 'F', 'G', 'H', 'I'};
+/* This should be called before accessing any other keyboard related feature
+ as it sets up all keyboard related peripherals */
void keyboard_init(){
for (int i = 0; i < number_of_rows; i++){
// setup rows (output open drain)
}
}
-
+/* This disable the all the row except for the specified one
+ It is usefull to test if a specific key is pressed */
void activate_row(uint8_t row_nb){
// set all row to 0 and then reenable selected row
for(int i =0; i < number_of_rows; i++){
us_wait(100);
}
+/* Scans the current state of the keyboard and returns an array of buttons struct
+ You can find the button struct definition in keyboard.h */
struct button* keyboard_scan(){
static struct button result_button_list[54] = {};
uint8_t i = 0;
#include "gpio_helper.h"
struct button{
- uint8_t column;
- char row;
- bool state;
+ uint8_t column; // ie: 2
+ char row; // ie: 'A'
+ bool state; // true is pressed and false released
};
-
+/* This should be called before accessing any other keyboard related feature
+ as it sets up all keyboard related peripherals */
void keyboard_init();
+
+/* Scans the current state of the keyboard and returns an array of buttons struct
+ You can find the button struct definition in keyboard.h */
struct button* keyboard_scan();
#endif
\ No newline at end of file
#include "laplace.h"
+/* Initialize all needed peripherals, should be called early in your program */
void laplace_init(){
- // Enable the GPIO peripheral in RCC.
+ /* led init */
enable_gpio_x_rcc(GPIO_B);
led_init();
- //col (in)
- enable_gpio_x_rcc(GPIO_C);
- //row (out)
- enable_gpio_x_rcc(GPIO_A);
+
+ /* keyboard init */
+ enable_gpio_x_rcc(GPIO_C); //column (in)
+ enable_gpio_x_rcc(GPIO_A); //row (out)
keyboard_init();
}
\ No newline at end of file
#include "led.h"
#include "keyboard.h"
+/* Initialize all needed peripherals, should be called early in your program */
void laplace_init();
#endif
\ No newline at end of file
// GPIOB for all the leds
uint8_t gpio_b = GPIO_B;
+/* This should be called before accessing any other led related feature
+ as it sets up all led related peripherals */
void led_init(){
// It should be set to push-pull low-speed output.
GPIOB->OTYPER &= ~(1 << BLUE_LED_PIN);
}
+/* Set the status of the red led
+ true -> ON
+ false -> OFF */
void set_led_red(bool state){
set_output_pin(gpio_b, RED_LED_PIN, state);
}
+/* Set the status of the green led
+ true -> ON
+ false -> OFF */
void set_led_green(bool state){
set_output_pin(gpio_b, GREEN_LED_PIN, state);
}
+/* Set the status of the blue led
+ true -> ON
+ false -> OFF */
void set_led_blue(bool state){
set_output_pin(gpio_b, BLUE_LED_PIN, state);
}
+/* Set the status of all 3 leds at the same time
+ true -> ON
+ false -> OFF */
void set_led_all(bool state){
set_output_pin(gpio_b, RED_LED_PIN, state);
set_output_pin(gpio_b, GREEN_LED_PIN, state);
#include "../device/stm32f730xx.h"
#include "gpio_helper.h"
+/* This should be called before accessing any other led related feature
+ as it sets up all led related peripherals */
void led_init();
+
+/* Set the status of the red led
+ true -> ON
+ false -> OFF */
void set_led_red(bool state);
+
+/* Set the status of the green led
+ true -> ON
+ false -> OFF */
void set_led_green(bool state);
+
+/* Set the status of the blue led
+ true -> ON
+ false -> OFF */
void set_led_blue(bool state);
+
+/* Set the status of all 3 leds at the same time
+ true -> ON
+ false -> OFF */
void set_led_all(bool state);
#endif
\ No newline at end of file
#include "time.h"
+/* Pause the os for x micro seconds */
void us_wait(uint8_t micro_seconds) {
for (volatile uint32_t i=0; i<loops_per_microsecond*micro_seconds; i++) {
__asm volatile("nop");
}
}
+/* Pause the os for x milli seconds */
void ms_wait(uint16_t milli_seconds) {
for (volatile uint32_t i=0; i<loops_per_millisecond*milli_seconds; i++) {
__asm volatile("nop");
#include "stdint.h"
+/* Pause the os for x micro seconds */
void us_wait(uint8_t micro_seconds);
+/* Pause the os for x milli seconds */
void ms_wait(uint16_t milli_seconds);
#endif
\ No newline at end of file
laplace_init();
ms_wait(2000);
set_led_green(true);
- while (1)
- {
+
+ // infinite loop
+ while (1){
struct button * keyboard_state = keyboard_scan();
+
for(int i =0; i < 54; i++){
if(keyboard_state[i].column == 4 && keyboard_state[i].row == 'H'){
+ if(keyboard_state[i].state){
+ set_led_blue(true);
+ }else{
+ set_led_blue(false);
+ }
+ }
+ if(keyboard_state[i].column == 3 && keyboard_state[i].row == 'H'){
if(keyboard_state[i].state){
set_led_green(true);
}else{
set_led_green(false);
}
- break;
+ }
+ if(keyboard_state[i].column == 2 && keyboard_state[i].row == 'H'){
+ if(keyboard_state[i].state){
+ set_led_red(true);
+ }else{
+ set_led_red(false);
+ }
}
}
}
-/** @file led.h
+/** @file main.h
*
- * @brief Control the led
+ * @brief The main programm
*
*/
#include "Laplace/keyboard.h"
#include "Laplace/time.h"
+/* our main function */
void main_entry();
#endif
\ No newline at end of file