FORMULA GENERAL numero imaginario o real

Dependencies:   mbed STM32F103C8T6_Hello

Committer:
JasperQM
Date:
Fri Sep 13 16:46:51 2019 +0000
Revision:
14:596a61f27f36
Parent:
13:485613003845
Formula General,resultado real o imaginario

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JasperQM 14:596a61f27f36 1 /* ###########################################################################
JasperQM 14:596a61f27f36 2 ** Archivo : main.c
JasperQM 14:596a61f27f36 3 ** Proyecto : STM32-F103C8_Plantilla
JasperQM 14:596a61f27f36 4 ** Procesador : STM32F103C8
JasperQM 14:596a61f27f36 5 ** Herramienta : Mbed
JasperQM 14:596a61f27f36 6 ** Version : Driver 01.01
JasperQM 14:596a61f27f36 7 ** Compilador : GNU C Compiler
JasperQM 14:596a61f27f36 8 ** Fecha/Hora : 14-07-2015, 11:48, # CodeGen: 0
JasperQM 14:596a61f27f36 9 ** Descripción :
JasperQM 14:596a61f27f36 10 ** Este proyecto muestra la configuracion del uso de la terminal serial
JasperQM 14:596a61f27f36 11 ** This module contains user's application code.
JasperQM 14:596a61f27f36 12 ** Componentes : Serial, etc .
JasperQM 14:596a61f27f36 13 ** Configuraciones : Se puede selecionar entre diferentes velocidades de transmision
JasperQM 14:596a61f27f36 14 ** Autores :
JasperQM 14:596a61f27f36 15 ** ATEAM Development Group:
JasperQM 14:596a61f27f36 16 ** - Antulio Morgado Valle
JasperQM 14:596a61f27f36 17 **
JasperQM 14:596a61f27f36 18 ** Versión : Beta
JasperQM 14:596a61f27f36 19 ** Revisión : A
JasperQM 14:596a61f27f36 20 ** Release : 0
JasperQM 14:596a61f27f36 21 ** Bugs & Fixes :
JasperQM 14:596a61f27f36 22 ** Date : 20/10/2019
JasperQM 14:596a61f27f36 23 ** Added support for Led_RGB
JasperQM 14:596a61f27f36 24 ** 22/09/2018
JasperQM 14:596a61f27f36 25 ** Added LCD Menu, Beta version (with bugs)
JasperQM 14:596a61f27f36 26 **
JasperQM 14:596a61f27f36 27 ** ###########################################################################*/
JasperQM 14:596a61f27f36 28 /*
JasperQM 14:596a61f27f36 29 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
JasperQM 14:596a61f27f36 30 : Includes
JasperQM 14:596a61f27f36 31 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
JasperQM 14:596a61f27f36 32 */
hudakz 0:ab218237069e 33 #include "mbed.h"
JasperQM 14:596a61f27f36 34 #include "stm32f103c8t6.h"
JasperQM 14:596a61f27f36 35 #include "PinNames.h"
JasperQM 14:596a61f27f36 36 #include "Serial.h"
JasperQM 14:596a61f27f36 37 #include "stdio.h"
JasperQM 14:596a61f27f36 38 #include "math.h"
hudakz 12:c24d2c99e2b6 39
JasperQM 14:596a61f27f36 40 /*
JasperQM 14:596a61f27f36 41 :...............................................................................
JasperQM 14:596a61f27f36 42 : Definiciones
JasperQM 14:596a61f27f36 43 :...............................................................................
JasperQM 14:596a61f27f36 44 */
JasperQM 14:596a61f27f36 45 #define on 0 // Estado para boton presionado
JasperQM 14:596a61f27f36 46 #define off 1 // Estado para boton sin presionar
JasperQM 14:596a61f27f36 47 #define hold 2 // Estado para boton mantenido
JasperQM 14:596a61f27f36 48 #define release 3 // Estado para boton liberado
JasperQM 14:596a61f27f36 49 #define FALSE 0 // Estado FASLO
JasperQM 14:596a61f27f36 50 #define TRUE 1 // Estado VERDADERO
JasperQM 14:596a61f27f36 51 /*
JasperQM 14:596a61f27f36 52 +-------------------------------------------------------------------------------
JasperQM 14:596a61f27f36 53 | Configuración de Puertos
JasperQM 14:596a61f27f36 54 +-------------------------------------------------------------------------------
JasperQM 14:596a61f27f36 55 */
JasperQM 14:596a61f27f36 56 // Host Pc terminal Comunication channel
JasperQM 14:596a61f27f36 57 Serial terminal (PA_2,PA_3); //Inicioaliza la comunicacion serial a la PC(RX,TX)
JasperQM 14:596a61f27f36 58 //Serial terminal(USBTX,USBRX,1115200);/TX,RX
JasperQM 14:596a61f27f36 59 /*
JasperQM 14:596a61f27f36 60 +-------------------------------------------------------------------------------
JasperQM 14:596a61f27f36 61 | Variables Globales de Usuario
JasperQM 14:596a61f27f36 62 +-------------------------------------------------------------------------------
JasperQM 14:596a61f27f36 63 */
JasperQM 14:596a61f27f36 64 uint32_t Baud_Rate = 115200 ; // Velocidad de transmision
JasperQM 14:596a61f27f36 65 /*
JasperQM 14:596a61f27f36 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JasperQM 14:596a61f27f36 67 | Definición de Funciones Prototipo y Rutinas de los Vectores de Interrupción
JasperQM 14:596a61f27f36 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JasperQM 14:596a61f27f36 69 */
JasperQM 14:596a61f27f36 70 void Setup(void); //Function que inicializa la tarjeta;
JasperQM 14:596a61f27f36 71 /*
JasperQM 14:596a61f27f36 72 END definitions */
JasperQM 14:596a61f27f36 73 /*
JasperQM 14:596a61f27f36 74 #===============================================================================
JasperQM 14:596a61f27f36 75 |
JasperQM 14:596a61f27f36 76 | P R O G R A M A P R I N C I P A L
JasperQM 14:596a61f27f36 77 |
JasperQM 14:596a61f27f36 78 #===============================================================================
JasperQM 14:596a61f27f36 79 */
JasperQM 14:596a61f27f36 80 int main()
JasperQM 14:596a61f27f36 81 {
JasperQM 14:596a61f27f36 82 void confSysClock();
JasperQM 14:596a61f27f36 83 void Setup();
JasperQM 14:596a61f27f36 84 //apartir de aqui creas tu programa
JasperQM 14:596a61f27f36 85 terminal.printf("Formula General(Chicharronera)");
JasperQM 14:596a61f27f36 86 int a,b,c;
JasperQM 14:596a61f27f36 87 printf("\t\t Introduce los valores de a,b,c\n");
JasperQM 14:596a61f27f36 88 float x1,x2,x3;
JasperQM 14:596a61f27f36 89 scanf("%i %i %i",&a,&b,&c);
JasperQM 14:596a61f27f36 90 x3= sqrt(double (b*b)- 4*a*c);
JasperQM 14:596a61f27f36 91 x1=(-b-x3)- 4*a*c/(2*a);
JasperQM 14:596a61f27f36 92 x2=(-b+x3)- 4*a*c/(2*a);
JasperQM 14:596a61f27f36 93 printf("el valor de x1 es %.2f ",x1);
JasperQM 14:596a61f27f36 94 printf("\nel valor de x2 es %.2f ",x2);
JasperQM 14:596a61f27f36 95 if(x3<0)
JasperQM 14:596a61f27f36 96 printf("\nla ecuacion es imaginaria");
JasperQM 14:596a61f27f36 97 else
JasperQM 14:596a61f27f36 98 printf("\nla ecuacion es real");
JasperQM 14:596a61f27f36 99 if(x3==0)
JasperQM 14:596a61f27f36 100 printf("\nla ecuacion es compleja");
JasperQM 14:596a61f27f36 101
JasperQM 14:596a61f27f36 102 }
JasperQM 14:596a61f27f36 103 /* END main */
JasperQM 14:596a61f27f36 104
JasperQM 14:596a61f27f36 105 /*
JasperQM 14:596a61f27f36 106 ................................................................................
JasperQM 14:596a61f27f36 107 : Rutinas de los Vectores de Interrupción
JasperQM 14:596a61f27f36 108 ................................................................................
JasperQM 14:596a61f27f36 109 */
hudakz 10:4b88be251088 110
JasperQM 14:596a61f27f36 111 /*
JasperQM 14:596a61f27f36 112 ______________________________________________________________________________
JasperQM 14:596a61f27f36 113 |
JasperQM 14:596a61f27f36 114 | Funciones Prototipo
JasperQM 14:596a61f27f36 115 |_______________________________________________________________________________
JasperQM 14:596a61f27f36 116 */
JasperQM 14:596a61f27f36 117 // Las Funciones Prototipo van aquí !
JasperQM 14:596a61f27f36 118 void Setup()
JasperQM 14:596a61f27f36 119 {
JasperQM 14:596a61f27f36 120 terminal.baud(Baud_Rate);
JasperQM 14:596a61f27f36 121 terminal.printf("System is wake up!.\n\t");
hudakz 0:ab218237069e 122 }
JasperQM 14:596a61f27f36 123 /* END routines */
JasperQM 14:596a61f27f36 124
JasperQM 14:596a61f27f36 125 /* END program */
JasperQM 14:596a61f27f36 126
JasperQM 14:596a61f27f36 127 /*+-----------------------------------------------------------------------------
JasperQM 14:596a61f27f36 128 *+ Conexión al Led Testigo:
JasperQM 14:596a61f27f36 129 *+
JasperQM 14:596a61f27f36 130 *+ Los leds se pueden conectar a cualquier pin que se declare como DigitalOut.
JasperQM 14:596a61f27f36 131 *+ El dispositivo puede drenar hasta 20ma por todas sus salidas a un voltaje de
JasperQM 14:596a61f27f36 132 *+ 3.3V, pero se recomienda no exceder de 1mA por salida.
JasperQM 14:596a61f27f36 133 *+ Esto se logra poniendo una resistencia limitadora de mínimo 330 Ohms.
JasperQM 14:596a61f27f36 134 *+
JasperQM 14:596a61f27f36 135 *+ 3.3V o 5V
JasperQM 14:596a61f27f36 136 *+ O
JasperQM 14:596a61f27f36 137 *+ |
JasperQM 14:596a61f27f36 138 *+ |
JasperQM 14:596a61f27f36 139 *+ /
JasperQM 14:596a61f27f36 140 *+ \ 1K
JasperQM 14:596a61f27f36 141 *+ /
JasperQM 14:596a61f27f36 142 *+ \ UTILIZANDO LÓGICA NEGATIVA
JasperQM 14:596a61f27f36 143 *+ |
JasperQM 14:596a61f27f36 144 *+ __|__
JasperQM 14:596a61f27f36 145 *+ \ /
JasperQM 14:596a61f27f36 146 *+ \ /
JasperQM 14:596a61f27f36 147 *+ \ /
JasperQM 14:596a61f27f36 148 *+ _\/_
JasperQM 14:596a61f27f36 149 *+ |
JasperQM 14:596a61f27f36 150 *+ |__________________________ PIN (Digital Out)
JasperQM 14:596a61f27f36 151 *+
JasperQM 14:596a61f27f36 152 *+
JasperQM 14:596a61f27f36 153 *+
JasperQM 14:596a61f27f36 154 *+
JasperQM 14:596a61f27f36 155 *+ 1K
JasperQM 14:596a61f27f36 156 *+
JasperQM 14:596a61f27f36 157 *+ ________/\ /\ /\ ____ PIN (Digital Out)
JasperQM 14:596a61f27f36 158 *+ | \/ \/ \/
JasperQM 14:596a61f27f36 159 *+ |
JasperQM 14:596a61f27f36 160 *+ |
JasperQM 14:596a61f27f36 161 *+ __|__
JasperQM 14:596a61f27f36 162 *+ \ /
JasperQM 14:596a61f27f36 163 *+ \ /
JasperQM 14:596a61f27f36 164 *+ \ / UTILIZANDO LÓGICA POSITIVA
JasperQM 14:596a61f27f36 165 *+ _\/_
JasperQM 14:596a61f27f36 166 *+ |
JasperQM 14:596a61f27f36 167 *+ |
JasperQM 14:596a61f27f36 168 *+ |
JasperQM 14:596a61f27f36 169 *+ __|__
JasperQM 14:596a61f27f36 170 *+ ___
JasperQM 14:596a61f27f36 171 *+ _
JasperQM 14:596a61f27f36 172 *+ _
JasperQM 14:596a61f27f36 173 *+
JasperQM 14:596a61f27f36 174 *+ GND
JasperQM 14:596a61f27f36 175 *+
JasperQM 14:596a61f27f36 176 +----------------------------------------------------------------------------
JasperQM 14:596a61f27f36 177 *+
JasperQM 14:596a61f27f36 178 *+ Powered by
JasperQM 14:596a61f27f36 179 *+
JasperQM 14:596a61f27f36 180 *+ T H E A N T U L I U ' S T E A M R&D Unltd
JasperQM 14:596a61f27f36 181 *+
JasperQM 14:596a61f27f36 182 *+ Research, Development, Systems, Equipment, Support & Spare Parts.
JasperQM 14:596a61f27f36 183 *+ (C) Copyright 1989-2019, All Rights Reserved
JasperQM 14:596a61f27f36 184 *+
JasperQM 14:596a61f27f36 185 *+ Welcome to The Beaners Proyect Community!
JasperQM 14:596a61f27f36 186 *+----------------------------------------------------------------------------*/
JasperQM 14:596a61f27f36 187
JasperQM 14:596a61f27f36 188 /* END Mbed */