Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F59004421
main.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Apr 19, 01:51
Size
1 KB
Mime Type
text/x-c
Expires
Sun, Apr 21, 01:51 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17102940
Attached To
R2671 HHRI-software
main.c
View Options
#include "main.h"
#include "communication.h"
#include "controller.h"
#include "drivers/adc.h"
#include "drivers/callback_timers.h"
#include "drivers/dac.h"
#include "drivers/h_bridge.h"
#include "drivers/hall.h"
#include "drivers/incr_encoder.h"
#include "drivers/strain_gauge.h"
#include "drivers/tachometer.h"
#include "lib/utils.h"
volatile
uint32_t
statusReg
=
0x00000000
;
// Main state register.
/**
* @brief Main function, setups all the drivers and controllers.
*/
int
main
(
void
)
{
// Setup the GPIOs and the interrupts.
RCC_AHB1PeriphClockCmd
(
RCC_AHB1Periph_GPIOA
|
RCC_AHB1Periph_GPIOB
|
RCC_AHB1Periph_GPIOC
|
RCC_AHB1Periph_GPIOD
|
RCC_AHB1Periph_GPIOE
,
ENABLE
);
NVIC_PriorityGroupConfig
(
NVIC_PriorityGroup_4
);
//
cbt_Init
();
// Setup the timers that will call the loops functions.
adc_Init
();
// Setup the ADC.
comm_Init
();
// Setup the communication module.
ctrl_Init
();
// Setup the controllers.
enc_Init
();
// Incremental encoders.
hb_Init
();
// H-bridge.
hb_Enable
();
// Delay to let the power electronics stabilize before calibrating the
// current sensor.
utils_DelayMs
(
200
);
adc_CalibrateCurrentSens
();
statusReg
|=
RUN_CURRENT_LOOP
;
dac_Init
();
// Init external sensors drivers, connected to the ADC.
hall_Init
(
ANIN1
);
//sg_Init(ANIN2);
//tac_Init(ANIN2);
comm_SendDebugMessage
(
"Initialization finished."
);
// Endless loop. The low priority functions are called here.
while
(
1
)
{
// Update the communication.
comm_Step
();
}
}
Event Timeline
Log In to Comment