2024-01-09 06:15 AM
Hi people,
I just work on a Dali project and trying to learn from the demo library I am getting some error can anyone PLEASE help me how to proceed.
I am trying in STM32G0
I am getting error as EXTI.Instruture undeclared i tried EXTI.Instruct but still its showing error 'NVIC_InitStructure' undeclared
hOW CAN I DECLARE THAT FUNCTIONS
void receive_tick(void)
{
// Because of the structure of current amplifier, input has
// to be negated
actual_val = get_DALIIN();
tick_count++;
// edge detected
if(actual_val != former_val)
{
switch(bit_count)
{
case 0:
if (tick_count > 2)
{
tick_count = 0;
bit_count = 1; // start bit
}
break;
case 17: // 1st stop bit
if(tick_count > 6) // stop bit error, no edge should exist
flag = ERR;
break;
default: // other bits
if(tick_count > 6)
{
if(bit_count < 9) // store bit in address byte
{
address |= (actual_val << (8-bit_count));
}
else // store bit in data byte
{
dataByte |= (actual_val << (16-bit_count));
}
bit_count++;
tick_count = 0;
}
break;
}
}else // voltage level stable
{
switch(bit_count)
{
case 0:
if(tick_count==8) // too long start bit
flag = ERR;
break;
case 17:
// First stop bit
if (tick_count==8)
{
if (actual_val==0) // wrong level of stop bit
{
flag = ERR;
}
else
{
bit_count++;
tick_count = 0;
}
}
break;
case 18:
// Second stop bit
if (tick_count==8)
{
flag = NO_ACTION;
//enable EXTI
EXTI_InitStructure.EXTI_Line = EXTI_LINE_6;
EXTI_InitStructure.EXTI_Mode = EXTI_MODE_INTERRUPT;
EXTI_InitStructure.EXTI_Trigger = EXTI_TRIGGER_FALLING;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
DataReceivedCallback(address,dataByte);
}
break;
default: // normal bits
if(tick_count==10)
{ // too long delay before edge
flag = ERR;
}
break;
}
}
former_val = actual_val;
if(flag==ERR)
{
flag = NO_ACTION;
//enable EXTI
EXTI_InitStructure.EXTI_Line = EXTI_LINE_6;
EXTI_InitStructure.EXTI_Mode = 'EXTI_MODE_INTERRUPT';
EXTI_InitStructure.EXTI_Trigger = EXTI_TRIGGER_FALLING;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
}
2024-01-09 06:24 AM
A search on Github turns on this:
typedef struct
{
uint32_t EXTI_Line; /*!< Specifies the EXTI lines to be enabled or disabled.
This parameter can be any combination of @ref EXTI_Lines */
EXTIMode_TypeDef EXTI_Mode; /*!< Specifies the mode for the EXTI lines.
This parameter can be a value of @ref EXTIMode_TypeDef */
EXTITrigger_TypeDef EXTI_Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines.
This parameter can be a value of @ref EXTITrigger_TypeDef */
FunctionalState EXTI_LineCmd; /*!< Specifies the new state of the selected EXTI lines.
This parameter can be set either to ENABLE or DISABLE */
}EXTI_InitTypeDef;
Not sure that'll help if you don't know how to define structures. Where did you get this code anyway?
2024-01-09 06:31 AM
Hi,
If you generate the code with CubeIDE , (?)
just define the pins you use for exti and in NVIC choose the INT priority. Then -> generate code -> and init functions are there.
2024-01-09 06:34 AM
Yes I found this in drivers but i am not sure why these used
if(flag==ERR)
{
flag = NO_ACTION;
//enable EXTI
EXTI_InitStructure.EXTI_Line = EXTI_LINE_6;
EXTI_InitStructure.EXTI_Mode = 'EXTI_MODE_INTERRUPT';
EXTI_InitStructure.EXTI_Trigger = EXTI_TRIGGER_FALLING;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
I got is from STM32F1 DALI slave library
2024-01-09 08:27 AM
This is probably based on SPL, which is an older library no longer supported by ST. There's no SPL for 'G0.
You should try to understand the functionality and then reproduce it on the 'G0, rather than just trying to port it blindly.
JW