Commit 420a13cb authored by Werner Sembach's avatar Werner Sembach
Browse files

Merge branch 'master' into parametrisierung_and_riddle2

# Conflicts:
#	inc/Util.h
#	main.c
#	src/ExternButton.cpp
#	src/ServoMotor.cpp
#	src/Util.cpp
parents 7510fc52 6bd86e39
......@@ -17,6 +17,7 @@ include_directories(${PROJECT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Inc)
include_directories(${PROJECT_SOURCE_DIR}/Drivers/CMSIS/Include)
include_directories(${PROJECT_SOURCE_DIR}/Drivers/CMSIS/Device/ST/STM32F4xx/Include)
include_directories(${PROJECT_SOURCE_DIR}/inc)
include_directories(${PROJECT_SOURCE_DIR}/riddles)
include_directories(${OPENCM3_PATH}/include)
set(LIBEZS_SOURCES
......@@ -43,7 +44,7 @@ set(STM32_SOURCES
Drivers/BSP/STM32F411E-Discovery/stm32f411e_discovery.c
Drivers/BSP/STM32F411E-Discovery/stm32f411e_discovery_accelerometer.c
Drivers/BSP/STM32F411E-Discovery/stm32f411e_discovery_gyroscope.c
#Drivers/BSP/STM32F411E-Discovery/stm32f411e_discovery_audio.c
Drivers/BSP/STM32F411E-Discovery/stm32f411e_discovery_audio.c
#Components
Drivers/BSP/Components/cs43l22/cs43l22.c
......@@ -74,7 +75,7 @@ set(STM32_SOURCES
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_crc.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_crc.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_msp_template.c
#Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_msp_template.c
#Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_timebase_tim_template.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_eth.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c
......@@ -114,7 +115,7 @@ set(STM32_SOURCES
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hash.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fsmc.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_fmpi2c_ex.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_timebase_rtc_wakeup_template.c
#Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_timebase_rtc_wakeup_template.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rng.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c
......@@ -155,6 +156,7 @@ SET(SRC_LIST
src/LeverKey.cpp
src/ServoMotor.cpp
src/Util.cpp
Middlewares/ST/STM32_Audio/Addons/PDM/pdm_filter.o
${LIBEZS_SOURCES}
${STM32_SOURCES}
)
......
# DIY, Ainigma und Ich
## Tagebuch eines Projects
## zehn Tage zum Wahnsinn mit EZS
### Tag -3
Es war an einem stürmischen Sommertag (Freitag 25.8)
ich war im Kino
Es war an einem stürmischen Sommertag (Freitag 25.8).
Ich war im Kino.
### Tag 1
Planung
Planung:
Was ich insgesamt tun will:
Die Zahnzäder sind zu groß - finde ich mit meinen begrenzten möglichkeiten auf dieser einsamen Insel eine Möglichkeit sie zu verkleinern? Ich weiß es nicht. Ein schrumpfstrahler wäre eine Möglichkeit
......@@ -23,22 +23,123 @@ Haushaltswaage
sortier platine ätzen
wernermitbringen:
waage
ladegerät und akku
kiste mitbringen
Werner mitbringen:
Waage
Ladegerät
Akku
Kiste
Heute:
Codeaufräumen
nach Akkus schauen
kleinere Zahnräder basteln
getan:
code aufgeräumt (it' pretty *.*)
Getan:
code aufgeräumt (it's pretty *.*)
Code den wir Dokumentieren für das "kochbuch" bestimmt
Sachen kosten geld (entscheidung entweder metall getriebe oder akku)
Sachen kosten geld (entscheidung entweder Metall getriebe oder Akku)
libEZS: utility funktionen von i4 hiwis
HAL update
std_hal_conf
stm32f4xx
libEZS: utility funktionen von i4 HiWis
### Tag 2
Planung:
Zahnräder neu Designen
Zahnräder Lasern (FabLab)
Kiste Bohren/Sägen (FabLab)
Einzelteile in Kiste befestigen (FabLab)
Doku fürs Kochbuch schreiben
Audio Treiber zum laufen bringen
Done:
Zahnräder neu Designen
Audio -> Morgen USB Stick + Adapter mitbringen
### Tag 3
Planung:
Positionierung der Zahnraeder
schliessmechanismus ausarbeiten
Raetsel 2 verbessern
Done:
Raetsel 2 verbessert
Draht fuer Schliessmnechanismus gebogen -> Problem mit Winkel und befestigunng
Positionierung der Zahnraeder mangels Fab Lab nicht gemacht
### Tag 4
Planung:
test Audio abspielen
Probleme: die gefundene Lib laesst sich zwar maken aber nicht aufs Board flashen und auch nach recherche keine Problemloesung in sicht
alternative kleinere lib gefunden -> code in unseren includiert
das laeuft bisher noch ueber den internen speicher und keinen USB stick -> sehr kleine Dateien nur abspielbar
zudem probleme mit der init
### Tag 5
Planung:
endlich den Audio Treiber zum Laufen bringen
wenn noch Zeit: Zahnraeder befestigen
Probleme:
probleme der init liegen an einer weitern init fkt die aufgerufen wird (was man laut API einfach tun soll und dann gehts). diese init ist aber broken und funktioniert nicht. Die Clk die da initialisiert werden soll ist aber auf einen anderen prozessor abgestimmt der einen hoeheren takt aushaelt.geschaetzte Zeit um die ganzen clks zu verstehen: eine woche. Aufwand wert? Nein.
versuch die groesser lib mit dem CubeMX flash problem trotzdem zum flashen zu kriegen: Skript, dass Makeflie erstellt gefunden unnd zum laufen gebracht. Make geht problemlos, make flash fehtlte das st-flash tool. St-link installiert. Problem: st-flash hat evtl nicht die noetigen rechte oder die Firmware auf dem board ist nicht kompatibel. Versuch das ganze auf dem privaten Laptop umzusetzen als root. Ergebnis: wenn nicht als root ausgefuehrt selbes Problem, wenn als root ausgefuehrt eine lib nicht gefunden die vorhanden ist und der angelegte PATH wirt ignoriert
ergebnis der nachfrage am Lehrstuhl mit unnseren Problemen: keiner weiss wie die EZS Boards so funktionieren.
### Tag 6
Planung:
Letzter versuch audio zum laufen zu bringen
Anlauf mit SW4STM32
Tagesablauf:
Früh war das fablab offen und ich wollte die löcher für die zahnräder bohren. bin aber über planung und 1 loch nicht hinausgekommen weil das fablab dann schon wieder für einen anderen workshop gräumt werden musste.
Danach habe ich auf einen usb stick ubuntu 14.04 installiert um darauf SW4STM32 zu installieren (ubuntu 14.04 einzige offizell unterstützte distro)
Beispiel Projekte liesen sich auch damit nicht compiler. Live linux auf usb 2.0 ist echt langsam und ich hab viel zeit mit warten verschwendet.
Problem letztendlich gefunden: .cproject datei hatte teilweise windows pfadnamen (aka \\ anstelle von /)
Flashen und ausführen schlägt immer noch fehl -> wir geben es auf den audio treiber zum laufen zu bringen
### Tag 7
Planung:
Zahnraeder einbauen, motortreiber verschrauben, EZS board fixierung bauen
Schalter zum Laufen bringen
Umsetzung:Zahnraeder eingebaut, Kippschalter zusammengeloetet, fuer rest keine Zeit da Fab lab geschlossen
Schalter versehentlich auf Pins gemapped, die zum flashen notwendig waren -> ne ganze Weile nach Fehler gesucht.
Schalter dann auf andere Pins gemapped. EZS Board verbindet sich manchmal nicht mit PC? Flashen auf privatem PC moeglich auf CIP rechner nicht.
exakt selben Code auf CIP geladen -> flashen nicht moeglich da das Board nicht gefunden. Auf Privatem PC nochmal versucht -> findet das board in der haelfte der faelle, wenn man den reset-knopf oft hintereinander betaetigt.
### Tag 8
Planung:
fixieren von: Motortreiber, EZS, Schaltern, Knopf, Servo, Akku (all unserer Hardware eben)
Tagesablauf:
Vormittag: Motortreiber festgeschraubt, Schalter festgeschraubt + Loecher in Aussenwand (nicht in der Reihenfolge)
Nachmittag: EZS Board entfernbare Halterung gebaut, KnopfLoch gemacht, Wartungsschlitz eingebaut, Servo festgeschraubt + "Oeffnungsstab" montiert, vorlaeuffige Akku fixierung (Plan fuer (viel) spaeter: anderer, kleinerer und besserer Akku
Abend: Schliessmechanismus monitert und getestet
\ No newline at end of file
This diff is collapsed.
......@@ -6,8 +6,8 @@
extern "C" {
#endif
void adc_init();
uint16_t adc_get(uint8_t channel);
void adc_init(void);
unsigned int adc_get(uint8_t channel);
#ifdef __cplusplus
}
......
......@@ -9,9 +9,9 @@
extern "C" {
#endif
void dc_init();
void dc_init(void);
void dc_set(uint8_t direction, uint8_t speed);
void dc_set_percent(uint8_t direction, double speed);
#ifdef __cplusplus
}
......
......@@ -9,9 +9,9 @@
extern "C" {
#endif
void button_init();
void button_init(void);
int button_get();
bool button_get(void);
#ifdef __cplusplus
}
......
......@@ -4,16 +4,16 @@
#define SERVO_0 0
#define SERVO_1 1
#define SERVO_2 2
#define SERVO_3 3
#ifdef __cplusplus
extern "C" {
#endif
void servo_init();
void servo_init(void);
void servo_set(uint8_t servo, uint8_t position);
void servo_set_percent(uint8_t servo, double position);
void servo_set_degree(uint8_t servo, double position);
#ifdef __cplusplus
}
......
#pragma once
#include <stdint.h>
#define LOWER_BOUND 0
#define UPPER_BOUND 1
#ifdef __cplusplus
extern "C" {
#endif
void all_init(void);
struct spring{
int threshold;
char direction;
......@@ -13,18 +19,17 @@ bool solved;
struct spring set_spring(int threshold, char direction, int power, bool solved);
void all_init();
void print_gyro();
void print_accelero();
void print_degree();
void print_gyro(void);
void print_accelero(void);
void print_degree(void);
double get_degree_short();
double get_degree_long();
double get_degree_max();
double get_degree_short(void);
double get_degree_long(void);
double get_degree_max(void);
bool simulate_spring(void);
bool simulate_spring(struct spring springs[], int len);
void block_spring(int pos);
bool block_spring(uint8_t direction, unsigned int position);
#ifdef __cplusplus
}
......
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
......@@ -12,6 +12,9 @@
#include "ServoMotor.h"
#include "Util.h"
#include "spring_riddle.h"
//#include "easy_riddle.h"
#define STACKSIZE (CYGNUM_HAL_STACK_SIZE_MINIMUM+1024)
#define WAVE_NAME "0:wave.wav"
static cyg_uint8 my_stack[STACKSIZE];
......@@ -38,7 +41,7 @@ void main_thread(cyg_addrword_t arg) {
the structs have have to be sorted ascending by threshold
*/
//riddle 1
//riddle 1
/*
struct spring riddle1[3];
riddle1[0] = set_spring(256, 'n', 0, false); //potty deadzone
......@@ -70,7 +73,7 @@ void main_thread(cyg_addrword_t arg) {
*/
//riddle2
/*
/*
bool springa_broken = false;
bool springb_broken = false;
......@@ -99,7 +102,7 @@ void main_thread(cyg_addrword_t arg) {
dc_set(0,0);
break;
}
button_pressed = button_get();
double degree_max = get_degree_max();
......@@ -130,9 +133,9 @@ void main_thread(cyg_addrword_t arg) {
if (springa_broken && springb_broken){
spring_broken = true;
}
}
*/
......@@ -157,7 +160,7 @@ void main_thread(cyg_addrword_t arg) {
dc_set(0,0);
break;
}
button_pressed = button_get();
//print_levers();
......
#pragma once
#include <stdint.h>
#include <stdio.h>
#include "ezs_io.h"
#include "DCMotor.h"
#include "ExternButton.h"
#include "ServoMotor.h"
#include "Util.h"
void riddle(void) {
while (1) {
if (button_get()) {
servo_set_percent(SERVO_0, 1.0);
}
else {
servo_set_percent(SERVO_0, 0.5);
}
}
}
\ No newline at end of file
#pragma once
#include <stdint.h>
#include <stdio.h>
#include <inttypes.h>
#include "ezs_io.h"
#include "DCMotor.h"
#include "ExternButton.h"
#include "ServoMotor.h"
#include "Util.h"
void riddle(void) {
bool button_pressed = false;
bool spring_broken = false;
bool upside_down = false;
servo_set_percent(SERVO_0, 0.5);
dc_set_percent(0, 0.0);
while (true) {
//poti protection
bool protection = block_spring(LOWER_BOUND, 256) && block_spring(UPPER_BOUND, 4096 - 256);
//check if solved
if(button_pressed && spring_broken && upside_down) {
ezs_printf("CONGRATULATIONS! YOU FINALLY MADE IT!\n");
servo_set_percent(SERVO_0, 1.0);
break;
}
button_pressed = button_get();
double degree_max = get_degree_max();
upside_down = (degree_max < 90);
//spring riddle can only be solved if button is pressed
if (!protection) {
if (spring_broken) {
dc_set_percent(0, 0.0);
}
else if (button_pressed) {
spring_broken = simulate_spring();
}
else if (!block_spring(UPPER_BOUND, 2048)) {
dc_set_percent(0, 0.0);
}
}
}
}
\ No newline at end of file
/*
* Original File adc-dac-printf.c modified by Lisa Dreier, Margit Haspel and Werner Sembach
*
* Original License Header:
*
* This file is part of the libopencm3 project.
*
* Copyright (C) 2013 Karl Palsson <karlp@tweak.net.au>
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ADC.h"
#include <libopencm3/stm32/adc.h>
......@@ -8,7 +31,23 @@ extern "C" void adc_init() {
rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]);
rcc_periph_clock_enable(RCC_ADC1);
gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);
// Uncomment pins that are used as ADC
//gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0); //ADC Channel 0 <> GPIO PA0
//gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1); //ADC Channel 1 <> GPIO PA1
//gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO2); //ADC Channel 2 <> GPIO PA2
//gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO3); //ADC Channel 3 <> GPIO PA3
//gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4); //ADC Channel 4 <> GPIO PA4
//gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO5); //ADC Channel 5 <> GPIO PA5
//gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO6); //ADC Channel 6 <> GPIO PA6
//gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO7); //ADC Channel 7 <> GPIO PA7
//gpio_mode_setup(GPIOB, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0); //ADC Channel 8 <> GPIO PB0
//gpio_mode_setup(GPIOB, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1); //ADC Channel 9 <> GPIO PB1
//gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0); //ADC Channel 10 <> GPIO PC0
gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1); //ADC Channel 11 <> GPIO PC1
//gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO2); //ADC Channel 12 <> GPIO PC2
//gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO3); //ADC Channel 13 <> GPIO PC3
//gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4); //ADC Channel 14 <> GPIO PC4
//gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO5); //ADC Channel 15 <> GPIO PC5
adc_power_off(ADC1);
adc_disable_scan_mode(ADC1);
......@@ -17,12 +56,11 @@ extern "C" void adc_init() {
adc_power_on(ADC1);
}
extern "C" uint16_t adc_get(uint8_t channel) {
extern "C" unsigned int adc_get(uint8_t channel) {