first commit

This commit is contained in:
pvvx 2016-09-23 07:21:45 +03:00
commit c399bf5be0
806 changed files with 421674 additions and 0 deletions

View file

@ -0,0 +1,14 @@
Example Description
This example describes how to use GPIO read/write by mbed api.
Requirement Components:
a LED
a push button
Pin name PC_4 and PC_5 map to GPIOC_4 and GPIOC_5:
- PC_4 as input with internal pull-high, connect a push button to this pin and ground.
- PC_5 as output, connect a LED to this pin and ground.
In this example, the LED is on when the push button is pressed.

View file

@ -0,0 +1,49 @@
/*
* Routines to access hardware
*
* Copyright (c) 2013 Realtek Semiconductor Corp.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*/
#include "device.h"
#include "gpio_api.h" // mbed
#include "main.h"
#define GPIO_LED_PIN PC_5
#define GPIO_PUSHBT_PIN PC_4
/**
* @brief Main program.
* @param None
* @retval None
*/
//int main_app(IN u16 argc, IN u8 *argv[])
void main(void)
{
gpio_t gpio_led;
gpio_t gpio_btn;
// Init LED control pin
gpio_init(&gpio_led, GPIO_LED_PIN);
gpio_dir(&gpio_led, PIN_OUTPUT); // Direction: Output
gpio_mode(&gpio_led, PullNone); // No pull
// Initial Push Button pin
gpio_init(&gpio_btn, GPIO_PUSHBT_PIN);
gpio_dir(&gpio_btn, PIN_INPUT); // Direction: Input
gpio_mode(&gpio_btn, PullUp); // Pull-High
while(1){
if (gpio_read(&gpio_btn)) {
// turn off LED
gpio_write(&gpio_led, 0);
}
else {
// turn on LED
gpio_write(&gpio_led, 1);
}
}
}