Javier Marcelo
/
STM32F103C8_RaicesReales
Programa de Raices Reales.
main.cpp@5:7bd28f4ca12b, 2019-10-25 (annotated)
- Committer:
- JavierMarcelo98
- Date:
- Fri Oct 25 14:21:11 2019 +0000
- Revision:
- 5:7bd28f4ca12b
- Parent:
- 4:e8498d695fc2
Programa de Raices Reales.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Antulius | 0:f680c41c1640 | 1 | /* ########################################################################### |
Antulius | 0:f680c41c1640 | 2 | ** Archivo : main.c |
ArturoRiosRamos | 3:7d496863c448 | 3 | ** Proyecto : STM32-103C8_Portada |
Antulius | 0:f680c41c1640 | 4 | ** Procesador : STM32F103C8 |
Antulius | 0:f680c41c1640 | 5 | ** Herramienta : Mbed |
Antulius | 0:f680c41c1640 | 6 | ** Version : Driver 01.01 |
Antulius | 0:f680c41c1640 | 7 | ** Compilador : GNU C Compiler |
Antulius | 0:f680c41c1640 | 8 | ** Fecha/Hora : 14-07-2015, 11:48, # CodeGen: 0 |
Antulius | 0:f680c41c1640 | 9 | ** Descripción : |
Antulius | 0:f680c41c1640 | 10 | ** Este proyecto muestra la configuración y uso de la Terminal Serial |
Antulius | 0:f680c41c1640 | 11 | ** This module contains user's application code. |
Antulius | 0:f680c41c1640 | 12 | ** Componentes : Timer, etc . |
Antulius | 0:f680c41c1640 | 13 | ** Configuraciones : Se puede seleccionar entre diferentes velocodades de |
Antulius | 0:f680c41c1640 | 14 | ** transmisión |
Antulius | 0:f680c41c1640 | 15 | ** Autores : |
Antulius | 0:f680c41c1640 | 16 | ** ATEAM Development Group: |
Antulius | 0:f680c41c1640 | 17 | ** - Antulio Morgado Valle |
JavierMarcelo98 | 4:e8498d695fc2 | 18 | ** - Marcelo Padron Javier |
Antulius | 0:f680c41c1640 | 19 | ** |
Antulius | 0:f680c41c1640 | 20 | ** Versión : Beta |
Antulius | 0:f680c41c1640 | 21 | ** Revisión : A |
Antulius | 0:f680c41c1640 | 22 | ** Release : 0 |
Antulius | 0:f680c41c1640 | 23 | ** Bugs & Fixes : |
JavierMarcelo98 | 4:e8498d695fc2 | 24 | ** Date : 22/10/2019 |
JavierMarcelo98 | 4:e8498d695fc2 | 25 | ** |
ArturoRiosRamos | 3:7d496863c448 | 26 | ** |
Antulius | 0:f680c41c1640 | 27 | ** |
Antulius | 0:f680c41c1640 | 28 | ** |
Antulius | 0:f680c41c1640 | 29 | ** ###########################################################################*/ |
Antulius | 0:f680c41c1640 | 30 | /* |
Antulius | 0:f680c41c1640 | 31 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
Antulius | 0:f680c41c1640 | 32 | : Includes |
Antulius | 0:f680c41c1640 | 33 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
Antulius | 0:f680c41c1640 | 34 | */ |
Antulius | 0:f680c41c1640 | 35 | |
Antulius | 0:f680c41c1640 | 36 | #include "stm32f103c8t6.h" |
Antulius | 0:f680c41c1640 | 37 | #include "mbed.h" |
Antulius | 0:f680c41c1640 | 38 | #include "Serial.h" |
Antulius | 0:f680c41c1640 | 39 | #include "stdio.h" |
Antulius | 0:f680c41c1640 | 40 | /* |
Antulius | 0:f680c41c1640 | 41 | :............................................................................... |
Antulius | 0:f680c41c1640 | 42 | : Definiciones |
Antulius | 0:f680c41c1640 | 43 | :............................................................................... |
Antulius | 0:f680c41c1640 | 44 | */ |
Antulius | 0:f680c41c1640 | 45 | #define on 0 // Estado para boton presionado |
Antulius | 0:f680c41c1640 | 46 | #define off 1 // Estado para boton sin presionar |
Antulius | 0:f680c41c1640 | 47 | #define hold 2 // Estado para boton mantenido |
Antulius | 0:f680c41c1640 | 48 | #define release 3 // Estado para boton liberado |
Antulius | 0:f680c41c1640 | 49 | #define FALSE 0 // Estado FALSO |
Antulius | 0:f680c41c1640 | 50 | #define TRUE 1 // Estado VERDADERO |
JavierMarcelo98 | 4:e8498d695fc2 | 51 | #define Ticker_Rate 1000 // Tiempo del Ticker |
JavierMarcelo98 | 4:e8498d695fc2 | 52 | ////////////////////////////////////////// Definimos las notas notas musicales y su frecuencia. |
Antulius | 0:f680c41c1640 | 53 | /* |
Antulius | 0:f680c41c1640 | 54 | +------------------------------------------------------------------------------- |
Antulius | 0:f680c41c1640 | 55 | | Configuración de Puertos |
Antulius | 0:f680c41c1640 | 56 | +------------------------------------------------------------------------------- |
JavierMarcelo98 | 4:e8498d695fc2 | 57 | */ |
JavierMarcelo98 | 5:7bd28f4ca12b | 58 | DigitalOut verde (LED1); // NC (Green_Led) |
JavierMarcelo98 | 4:e8498d695fc2 | 59 | DigitalOut Led_Monitor (PB_1); // Led monitor de la Tarjeta STM32F103C8 |
JavierMarcelo98 | 4:e8498d695fc2 | 60 | Serial terminal (PA_2, PA_3); // Inicializa la comunicación serial a la PC (Tx,Rx) |
JavierMarcelo98 | 4:e8498d695fc2 | 61 | //Serial terminal(USBTX, USBRX,115200);// Tx, Rx Baud Rate - Terminal Serial por USB @ 115,200 Bauds |
Antulius | 0:f680c41c1640 | 62 | |
Antulius | 0:f680c41c1640 | 63 | /* |
Antulius | 0:f680c41c1640 | 64 | +------------------------------------------------------------------------------- |
JavierMarcelo98 | 4:e8498d695fc2 | 65 | | Variables Globales de Usuario |
JavierMarcelo98 | 4:e8498d695fc2 | 66 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Antulius | 0:f680c41c1640 | 67 | */ |
Antulius | 0:f680c41c1640 | 68 | /* |
Antulius | 0:f680c41c1640 | 69 | | Definición de Funciones Prototipo y Rutinas de los Vectores de Interrupción |
Antulius | 0:f680c41c1640 | 70 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Antulius | 0:f680c41c1640 | 71 | */ |
ArturoRiosRamos | 3:7d496863c448 | 72 | void Portada(); |
JavierMarcelo98 | 5:7bd28f4ca12b | 73 | void Calculos(); |
Antulius | 0:f680c41c1640 | 74 | void Setup(void); |
Antulius | 0:f680c41c1640 | 75 | /* END definitions */ |
Antulius | 0:f680c41c1640 | 76 | |
Antulius | 0:f680c41c1640 | 77 | /* |
Antulius | 0:f680c41c1640 | 78 | #=============================================================================== |
Antulius | 0:f680c41c1640 | 79 | | |
Antulius | 0:f680c41c1640 | 80 | | P R O G R A M A P R I N C I P A L |
Antulius | 0:f680c41c1640 | 81 | | |
Antulius | 0:f680c41c1640 | 82 | #=============================================================================== |
Antulius | 0:f680c41c1640 | 83 | */ |
Antulius | 0:f680c41c1640 | 84 | int main() |
JavierMarcelo98 | 4:e8498d695fc2 | 85 | { // Inicialización de variables, puertos e interrupciones // Configure system clock (72MHz HSE clock, 48MHz USB clock) |
Antulius | 0:f680c41c1640 | 86 | Setup(); // Inicialización del sistema |
JavierMarcelo98 | 4:e8498d695fc2 | 87 | Portada(); //Mandar a llamar a la funcion Portada. |
JavierMarcelo98 | 5:7bd28f4ca12b | 88 | Calculos(); //Mandar a llamar a la funcion Calculos. |
ArturoRiosRamos | 3:7d496863c448 | 89 | } |
Antulius | 0:f680c41c1640 | 90 | /* END main */ |
Antulius | 0:f680c41c1640 | 91 | |
Antulius | 0:f680c41c1640 | 92 | /* |
Antulius | 0:f680c41c1640 | 93 | ................................................................................ |
Antulius | 0:f680c41c1640 | 94 | : Rutinas de los Vectores de Interrupción |
Antulius | 0:f680c41c1640 | 95 | ................................................................................ |
Antulius | 0:f680c41c1640 | 96 | */ |
Antulius | 0:f680c41c1640 | 97 | |
Antulius | 0:f680c41c1640 | 98 | /* END Events */ |
Antulius | 0:f680c41c1640 | 99 | /* |
Antulius | 0:f680c41c1640 | 100 | ________________________________________________________________________________ |
Antulius | 0:f680c41c1640 | 101 | | |
Antulius | 0:f680c41c1640 | 102 | | Funciones Prototipo |
Antulius | 0:f680c41c1640 | 103 | |_______________________________________________________________________________ |
Antulius | 0:f680c41c1640 | 104 | */ |
Antulius | 0:f680c41c1640 | 105 | // Las Funciones Prototipo van aquí ! |
Antulius | 0:f680c41c1640 | 106 | void Setup() |
Antulius | 0:f680c41c1640 | 107 | { |
Antulius | 0:f680c41c1640 | 108 | // terminal.baud(Baud_Rate); // Se configura la velocidad de transmisión e inicia la comunicación serial. |
JavierMarcelo98 | 4:e8498d695fc2 | 109 | terminal.baud(115200); // Se configura la velocidad de transmisión e inicia la comunicación serial. |
JavierMarcelo98 | 5:7bd28f4ca12b | 110 | } |
JavierMarcelo98 | 5:7bd28f4ca12b | 111 | void Portada()//Funcion Portada |
JavierMarcelo98 | 4:e8498d695fc2 | 112 | { |
JavierMarcelo98 | 5:7bd28f4ca12b | 113 | terminal.printf("\n\r\t\e[1;32m0101 0101 010101 01 10 0101 0101 0101 0101 0101 0101 0101 01 10 0101 0101\e[0m"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 114 | terminal.printf("\n\r\t\e[1;32m01 01 01 010 010 01 0 0 1 01 0 1 10 01 010 10 01 0 1\e[0m"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 115 | terminal.printf("\n\r\t\e[1;32m0101 0101 01 01 1 10 0101 1 0101 01 0101 10 0101 01 1 10 01 0 1\e[0m"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 116 | terminal.printf("\n\r\t\e[1;32m01 01 01 01 10 01 0 0 1 01 0 1 10 01 01 010 01 0 1\e[0m"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 117 | terminal.printf("\n\r\t\e[1;32m0101 0101 010101 01 10 0101 0101 0 1 0101 0 1 10 0101 01 10 0101 0101\e[0m"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 118 | terminal.printf("\n\n\r\t\e[1;32m \'NUESTROS COLORES VERDE \e[0m\e[1;37mY BLANCO, POR QUE EL\e[0m\e[1;31m ROJO LO LLEVAMOS EN LA SANGRE!!!\'\e[0m\n\n"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 119 | terminal.printf("\n\r\t\t\e[1;37m ESCUELA SUPERIOR DE INGENIERIA MECANICA Y ELECTRICA\e[0m"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 120 | terminal.printf("\n\n\r\t\t\e[1;37m INGENIERIA EN COMUNICACIONES Y ELECTRONICA\e[0m"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 121 | terminal.printf("\n\n\r\t\t\e[1;37m ANALISIS NUMERICO\e[0m"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 122 | terminal.printf("\n\n\r\t\t\e[1;37m PROGRAMA: RAICES REALES\e[0m"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 123 | terminal.printf("\n\n\r\t\t\e[1;37m ALUMNO: MARCELO PADRON JAVIER\e[0m"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 124 | terminal.printf("\n\n\r\t\t\e[1;37m GRUPO: 4CV2\e[0m\n\n"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 125 | wait(3.0);//Retardo de 3 segundos |
JavierMarcelo98 | 4:e8498d695fc2 | 126 | } |
JavierMarcelo98 | 5:7bd28f4ca12b | 127 | void Calculos() |
JavierMarcelo98 | 4:e8498d695fc2 | 128 | { |
JavierMarcelo98 | 5:7bd28f4ca12b | 129 | float a,b,c; |
JavierMarcelo98 | 5:7bd28f4ca12b | 130 | float x1,x2,x3,ax,bx; |
JavierMarcelo98 | 5:7bd28f4ca12b | 131 | terminal.printf("\n\r\t\e[1;37mIntroduce los valores de a, b, c.\e[0m\n"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 132 | terminal.printf("\n\r\t\e[1;37ma = \e[0m\n"); a = terminal.getc(); |
JavierMarcelo98 | 5:7bd28f4ca12b | 133 | terminal.printf("\n\r\t\e[1;37mb = \e[0m\n"); b = terminal.getc(); |
JavierMarcelo98 | 5:7bd28f4ca12b | 134 | terminal.printf("\n\r\t\e[1;37mc = \e[0m\n"); c = terminal.getc(); |
JavierMarcelo98 | 5:7bd28f4ca12b | 135 | c= sqrt(float (b*b)- 4*a*c); |
JavierMarcelo98 | 5:7bd28f4ca12b | 136 | ax=(-b-x3); |
JavierMarcelo98 | 5:7bd28f4ca12b | 137 | x1=ax/(2*a); |
JavierMarcelo98 | 5:7bd28f4ca12b | 138 | bx=(-b+x3); |
JavierMarcelo98 | 5:7bd28f4ca12b | 139 | x2=(-b+x3)/(2*a); |
JavierMarcelo98 | 5:7bd28f4ca12b | 140 | terminal.printf("\n\r\t\e[1;37mEl valor de x1 es %.2f \e[0m\n",x1); |
JavierMarcelo98 | 5:7bd28f4ca12b | 141 | terminal.printf("\n\r\t\e[1;37mEl valor de x2 es %.2f \e[0m\n",x2); |
JavierMarcelo98 | 5:7bd28f4ca12b | 142 | if(ax>0 || bx>0) |
JavierMarcelo98 | 4:e8498d695fc2 | 143 | { |
JavierMarcelo98 | 5:7bd28f4ca12b | 144 | terminal.printf("\n\r\t\e[1;37mLa ecuacion es real\e[0m\n"); |
JavierMarcelo98 | 4:e8498d695fc2 | 145 | } |
JavierMarcelo98 | 5:7bd28f4ca12b | 146 | else |
JavierMarcelo98 | 5:7bd28f4ca12b | 147 | { |
JavierMarcelo98 | 5:7bd28f4ca12b | 148 | terminal.printf("\n\r\t\e[1;37mLa ecuacion no es real\e[0m\n"); |
JavierMarcelo98 | 5:7bd28f4ca12b | 149 | } |
JavierMarcelo98 | 5:7bd28f4ca12b | 150 | } |
Antulius | 0:f680c41c1640 | 151 | /* END routines */ |
Antulius | 0:f680c41c1640 | 152 | |
Antulius | 0:f680c41c1640 | 153 | /* END program */ |
Antulius | 0:f680c41c1640 | 154 | |
Antulius | 0:f680c41c1640 | 155 | /* END documentation */ |
Antulius | 0:f680c41c1640 | 156 | /* |
ArturoRiosRamos | 3:7d496863c448 | 157 | |
Antulius | 0:f680c41c1640 | 158 | +-------------------------------------------------------------------------------- |
Antulius | 0:f680c41c1640 | 159 | | |
Antulius | 0:f680c41c1640 | 160 | | T H E A N T U L I U S T E A M |
Antulius | 0:f680c41c1640 | 161 | | Research, Development, Systems Equipment, Support & Spare Parts I n c. |
Antulius | 0:f680c41c1640 | 162 | | (C) Copyright 1989-2014, All rigths Reserved |
Antulius | 0:f680c41c1640 | 163 | | |
Antulius | 0:f680c41c1640 | 164 | | This program is licensed under rules of |
Antulius | 0:f680c41c1640 | 165 | | THE BEANERS TECHNOLOGIES PROYECT |
Antulius | 0:f680c41c1640 | 166 | +------------------------------------------------------------------------------- |
Antulius | 0:f680c41c1640 | 167 | */ |
Antulius | 0:f680c41c1640 | 168 | /* END Mbed */ |