Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:9f7581d1af6f
- Child:
- 1:c0ed6c52c441
diff -r 000000000000 -r 9f7581d1af6f main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Jun 26 18:54:11 2019 +0000
@@ -0,0 +1,208 @@
+/* ###########################################################################
+** Archivo : main.c
+** Proyecto : STM32-F103C8_Plantilla
+** Procesador : STM32F103C8
+** Herramienta : Mbed
+** Version : Driver 01.01
+** Compilador : GNU C Compiler
+** Fecha/Hora : 14-07-2015, 11:48, # CodeGen: 0
+** Descripción :
+** Este proyecto hace...
+** This module contains user's application code.
+** Componentes : GPIO, Timer, etc .
+** Configuraciones : Includes, Stacks y Drivers externos
+** Autores :
+** ATEAM Development Group:
+** - Antulio Morgado Valle
+**
+** Versión : Beta
+** Revisión : A
+** Release : 0
+** Bugs & Fixes :
+** Date : 20/10/2019
+** Added support for Led_RGB
+** 22/09/2018
+** Added LCD Menu, Beta version (with bugs)
+**
+** ###########################################################################*/
+/*
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+: Includes
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+*/
+#include "mbed.h"
+#include "stm32f103c8t6.h"
+//#include "stm32f10x.h"
+#include "PinNames.h"
+//#include "SysClockConf.h"
+//#include "AnalogIn.h"
+//#include "Led_RGB.h"
+//#include "Serial.h"
+//#include "stdio.h"
+
+/*
+:...............................................................................
+: Definiciones
+:...............................................................................
+*/
+#define on 0 // Estado para boton presionado
+#define off 1 // Estado para boton sin presionar
+#define hold 2 // Estado para boton mantenido
+#define release 3 // Estado para boton liberado
+#define Ticker_Rate 1000 // Periodo de interrupción (us)
+/*
++-------------------------------------------------------------------------------
+| Configuración de Puertos
++-------------------------------------------------------------------------------
+*/
+//confSysClock(); // Configure system clock (72MHz HSE clock, 48MHz USB clock)
+Ticker TimerInt; // Inicializa la Interrupción por Timer
+DigitalOut led_monitor(LED1); // Inicializa el LED Monitor
+DigitalOut led_testigo(PA_1); // Inicializa el LED Testigo
+Serial terminal(PA_2, PA_3); // Inicializa la Comunicación Serial a la PC
+PwmOut servo(PA_7); // Inicializa el PWM
+AnalogIn sensor1 (PB_0); // Inicializa Canal Analógico para sensor 1
+/*
++-------------------------------------------------------------------------------
+| Variables Globales de Usuario
++-------------------------------------------------------------------------------
+*/
+uint16_t Rate=Ticker_Rate/2; // Velocidad de barrido (500us = 0.5ms)
+uint16_t counter=250; // Cuenta inicial de 250us
+/* END variables */
+
+/*
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+| Definición de Funciones Prototipo y Rutinas de los Vectores de Interrupción
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+*/
+ // Las Definiciones de Funciones Prototipo
+ // y Apuntadores a Vectores de Interrupciones van aquí !
+void TimerInt_OnInterrupt(void);
+void Blinking_Led(void);
+/* END prototypes */
+
+/* END definitions */
+/*
+#===============================================================================
+|
+| P R O G R A M A P R I N C I P A L
+|
+#===============================================================================
+*/
+int main()
+{ // Inicialización de variables, puertos e interrupciones
+confSysClock(); // Inicialización del Sistema, Configure system clock (72MHz HSE clock, 48MHz USB clock)
+TimerInt.attach_us(&TimerInt_OnInterrupt, Ticker_Rate); // Le asigna el periodo de interrupción de 1ms (Ticker_Rate=1000)
+
+terminal.baud(115200); // Se configura la velocidad de transmisión e inicia la comunicación serial.
+terminal.printf(" System is Wake Up!.\n\r");
+
+ while (true) // El Lazo del Programa principal está aquí !!!
+ {
+ Blinking_Led(); // Parapadeo del LED por Software
+ servo = sensor1.read(); //
+ terminal.printf("Blink \r\n");
+ }
+}
+/* END main */
+
+/*
+................................................................................
+: Rutinas de los Vectores de Interrupción
+................................................................................
+*/
+ // Las Rutinas de Atención a Interrupciones van aquí !
+void TimerInt_OnInterrupt() // Rutina de Atención al Ticker
+{
+ counter--; // Aquí va la Rutina de Servicio !
+ if (!counter)
+ {
+ terminal.printf("Counter Finish! \r\n");
+ led_monitor = !led_monitor; // Parapadeo del LED por Interrupción (LED Toggled)
+ counter = Rate; // Restablece el contador, Le asigna el periodo de 0.5ms (Rate=500)
+ }
+}
+/* END Events */
+/*
+________________________________________________________________________________
+|
+| Funciones Prototipo
+|_______________________________________________________________________________
+*/
+ // Las Funciones Prototipo van aquí !
+void Blinking_Led() // Software Blinking routine for LED
+{
+ // The on-board LED is connected, via a resistor, to +3.3V (not to GND).
+ // So to turn the LED on or off we have to set it to 0 or 1 respectively
+ led_testigo = 1; // turn the LED on (using Positive Logic)
+ wait_ms(200); // 200 millisecond
+ led_testigo = 0; // turn the LED off (using Positive Logic)
+ wait_ms(1000); // 1000 millisecond
+}
+/* END functions */
+
+/* END program */
+
+/*+-----------------------------------------------------------------------------
+*+ Conexión al Led Testigo:
+*+
+*+ Los leds se pueden conectar a cualquier pin que se declare como DigitalOut.
+*+ El dispositivo puede drenar hasta 20ma por todas sus salidas a un voltaje de
+*+ 3.3V, pero se recomienda no exceder de 1mA por salida.
+*+ Esto se logra poniendo una resistencia limitadora de mínimo 330 Ohms.
+*+
+*+ 3.3V o 5V
+*+ O
+*+ |
+*+ |
+*+ /
+*+ \ 1K
+*+ /
+*+ \ UTILIZANDO LÓGICA NEGATIVA
+*+ |
+*+ ___|___
+*+ \ /
+*+ \ /
+*+ \ /
+*+ __\/__
+*+ |
+*+ |__________________________ PIN (Digital Out)
+*+
+*+
+*+
+*+
+*+ 1K
+*+
+*+ _________/\ /\ /\ _____ PIN (Digital Out)
+*+ | \/ \/ \/
+*+ |
+*+ |
+*+ ___|___
+*+ \ /
+*+ \ /
+*+ \ / UTILIZANDO LÓGICA POSITIVA
+*+ __\/__
+*+ |
+*+ |
+*+ |
+*+ ___|___
+*+ _____
+*+ ___
+*+ _
+*+
+*+ GND
+*+
+*+----------------------------------------------------------------------------*
+*+
+*+ Powered by
+*+
+*+ T H E A N T U L I U ' S T E A M R&D Unltd
+*+
+*+ Research, Development, Systems, Equipment, Support & Spare Parts.
+*+ (C) Copyright 1989-2019, All Rights Reserved
+*+
+*+ Welcome to The Beaners Proyect Community!
+*+----------------------------------------------------------------------------*/
+
+/* END Mbed */
\ No newline at end of file