Hallo liebe mikrocontroller Community,
ich nutze die neuste Version von EM::Blocks und habe ein kleines Problem
mit meinen Programm. Ich erstelle eine klasse mit der ich einen Ausgang
definiere und habe zwei funktionen um den Ausgang high oder low zu
setzen. Mit dem IAR Compiler funktioniert alles. Wenn ich es allerdings
mit EM::Blocks übersetze funktioniert das compilieren aber wenn er die
Klasse erstellen will springt das Programm in die assert_failed
Funktion. Ich denke mir fehlen nur ein paar Einstellungen aber ich komme
nicht drauf welche....
Mein Code:
main.cpp
1 | #include "stm32f10x.h"
|
2 | //#include "drv_LED.h"
|
3 | #include "output.h"
|
4 |
|
5 | int main()
|
6 | {
|
7 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
8 |
|
9 | output LED(GPIO_Pin_5, GPIOB, GPIO_Mode_Out_PP, GPIO_Speed_50MHz);
|
10 |
|
11 | while(1)
|
12 | {
|
13 | LED.high();
|
14 | //LED.low();
|
15 | }
|
16 | }
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | #ifdef __cplusplus
|
22 | extern "C" {
|
23 | #endif
|
24 |
|
25 | void assert_failed(uint8_t* file, uint32_t line)
|
26 | {
|
27 |
|
28 | while(1)
|
29 | {
|
30 | // parameter error
|
31 | }
|
32 | }
|
33 |
|
34 |
|
35 |
|
36 | #ifdef __cplusplus
|
37 | }
|
38 | #endif
|
output.cpp
1 | #include "stm32f10x.h"
|
2 | #include "output.h"
|
3 |
|
4 | output::output()
|
5 | {
|
6 |
|
7 | }
|
8 |
|
9 | output::output(uint16_t Pin, GPIO_TypeDef* Port, GPIOMode_TypeDef Mode, GPIOSpeed_TypeDef Speed)
|
10 | : Pin(Pin), Port(Port)
|
11 | {
|
12 | GPIO_InitTypeDef GPIO_InitStructure;
|
13 |
|
14 | /* Configure the GPIO_LED pin */
|
15 | GPIO_InitStructure.GPIO_Pin = Pin;
|
16 | GPIO_InitStructure.GPIO_Mode = Mode;
|
17 | GPIO_InitStructure.GPIO_Speed = Speed;
|
18 |
|
19 | GPIO_Init(Port, &GPIO_InitStructure);
|
20 | }
|
21 |
|
22 | output::~output()
|
23 | {
|
24 |
|
25 | }
|
26 |
|
27 | void output::high()
|
28 | {
|
29 | GPIO_WriteBit(Port, Pin, Bit_SET);
|
30 | }
|
31 |
|
32 | void output::low()
|
33 | {
|
34 | GPIO_WriteBit(Port, Pin, Bit_RESET);
|
35 | }
|
Die Einstellungen sind fast alle wie die EM::Blocks automatisch erstellt
nur beim Linker habe ich eingestellt das er C++ libaries nutzen soll.
Danke schon einmal.
Gruß jonas