This commit is contained in:
crinq
2015-01-10 22:22:46 +01:00
4 changed files with 43 additions and 29 deletions

42
src/comps/led.comp Normal file
View File

@@ -0,0 +1,42 @@
COMP(led);
HAL_PIN(r) = 0.0;
HAL_PIN(g) = 0.0;
HAL_PIN(y) = 0.0;
INIT(
RCC_AHB1PeriphClockCmd(LED_R_IO_RCC, ENABLE);
RCC_AHB1PeriphClockCmd(LED_Y_IO_RCC, ENABLE);
RCC_AHB1PeriphClockCmd(LED_G_IO_RCC, ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = LED_R_PIN;
GPIO_Init(LED_R_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = LED_Y_PIN;
GPIO_Init(LED_Y_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = LED_G_PIN;
GPIO_Init(LED_G_PORT, &GPIO_InitStructure);
);
RT_OUT(
if(PIN(r) > 0)
GPIO_SetBits(LED_R_PORT,LED_R_PIN);
else
GPIO_ResetBits(LED_R_PORT,LED_R_PIN);
if(PIN(g) > 0)
GPIO_SetBits(LED_G_PORT,LED_G_PIN);
else
GPIO_ResetBits(LED_G_PORT,LED_G_PIN);
if(PIN(y) > 0)
GPIO_SetBits(LED_Y_PORT,LED_Y_PIN);
else
GPIO_ResetBits(LED_Y_PORT,LED_Y_PIN);
);
ENDCOMP;

View File

@@ -173,7 +173,6 @@ void link_ac_sync_enc(){//berger lahr
void DMA2_Stream0_IRQHandler(void){ //5kHz
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);
GPIO_SetBits(GPIOB,GPIO_Pin_4);
GPIO_ResetBits(LED_R_PORT,LED_R_PIN);//led
int freq = 5000;
float period = 1.0 / freq;
//GPIO_ResetBits(GPIOB,GPIO_Pin_3);//messpin
@@ -219,11 +218,6 @@ int main(void)
setup();
//ADC_SoftwareStartConv(ADC1);
GPIO_SetBits(LED_R_PORT,LED_R_PIN);//led
GPIO_SetBits(LED_Y_PORT,LED_Y_PIN);//led
GPIO_SetBits(LED_G_PORT,LED_G_PIN);//led
#include "comps/frt.comp"
#include "comps/rt.comp"
@@ -245,6 +239,7 @@ int main(void)
#include "comps/auto.comp"
#include "comps/test.comp"
#include "comps/led.comp"
//#include "comps/vel_observer.comp"
@@ -286,7 +281,6 @@ int main(void)
while(1) // Do not exit
{
Wait(10);
GPIO_SetBits(LED_R_PORT,LED_R_PIN);//led
period = systime/1000.0 + (1.0 - SysTick->VAL/RCC_Clocks.HCLK_Frequency)/1000.0 - lasttime;
lasttime = systime/1000.0 + (1.0 - SysTick->VAL/RCC_Clocks.HCLK_Frequency)/1000.0;
for(int i = 0; i < hal.nrt_func_count; i++){

View File

@@ -24,7 +24,6 @@ void setup(){
setup_usart();
setup_res();
setup_led();
// systick timer
systime = 0;
@@ -40,26 +39,6 @@ void setup(){
#endif
}
void setup_led(){
RCC_AHB1PeriphClockCmd(LED_R_IO_RCC, ENABLE);
RCC_AHB1PeriphClockCmd(LED_Y_IO_RCC, ENABLE);
RCC_AHB1PeriphClockCmd(LED_G_IO_RCC, ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = LED_R_PIN;
GPIO_Init(LED_R_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = LED_Y_PIN;
GPIO_Init(LED_Y_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = LED_G_PIN;
GPIO_Init(LED_G_PORT, &GPIO_InitStructure);
}
void setup_usart(){
GPIO_InitTypeDef GPIO_InitStruct;
USART_InitTypeDef USART_InitStruct;

View File

@@ -31,7 +31,6 @@ void setup();
void setup_res();
void setup_pwm();
void setup_usart();
void setup_led();
void SysTick_Handler(void);
volatile unsigned int systime;