Skip to content

Commit

Permalink
Added GPIO driving
Browse files Browse the repository at this point in the history
  • Loading branch information
siorpaes committed Jun 13, 2018
1 parent 1a3f447 commit 97a40be
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 13 deletions.
4 changes: 4 additions & 0 deletions Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@

#define B1_Pin GPIO_PIN_13
#define B1_GPIO_Port GPIOC
#define OUT1_Pin GPIO_PIN_2
#define OUT1_GPIO_Port GPIOC
#define OUT2_Pin GPIO_PIN_3
#define OUT2_GPIO_Port GPIOC
#define USART_TX_Pin GPIO_PIN_2
#define USART_TX_GPIO_Port GPIOA
#define USART_RX_Pin GPIO_PIN_3
Expand Down
2 changes: 1 addition & 1 deletion MDK-ARM/Nucleo-F072RB-DTMF.uvoptx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>ST-LINKIII-KEIL_SWO</Key>
<Name>-U-O142 -O10446 -SF480 -C0 -A0 -I0 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F0xx_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F072RBTx$CMSIS\Flash\STM32F0xx_128.FLM)</Name>
<Name>-U-O142 -O2254 -SF480 -C0 -A0 -I0 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F0xx_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F072RBTx$CMSIS\Flash\STM32F0xx_128.FLM)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
Expand Down
2 changes: 1 addition & 1 deletion MDK-ARM/Nucleo-F072RB-DTMF.uvprojx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
<MiscControls></MiscControls>
<Define>USE_HAL_DRIVER,STM32F072xB</Define>
<Undefine></Undefine>
<IncludePath>../Inc; ../Drivers/STM32F0xx_HAL_Driver/Inc; ../Drivers/STM32F0xx_HAL_Driver/Inc/Legacy; ../Drivers/CMSIS/Device/ST/STM32F0xx/Include; ../Drivers/CMSIS/Include; ..\DTMF</IncludePath>
<IncludePath>../Inc; ../Drivers/STM32F0xx_HAL_Driver/Inc; ../Drivers/STM32F0xx_HAL_Driver/Inc/Legacy; ../Drivers/CMSIS/Device/ST/STM32F0xx/Include; ../Drivers/CMSIS/Include; ..\DTMF</IncludePath>
</VariousControls>
</Cads>
<Aads>
Expand Down
36 changes: 25 additions & 11 deletions Nucleo-F072RB-DTMF.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,22 @@ Mcu.Name=STM32F072R(8-B)Tx
Mcu.Package=LQFP64
Mcu.Pin0=PC13
Mcu.Pin1=PC14-OSC32_IN
Mcu.Pin10=PB13
Mcu.Pin11=PA13
Mcu.Pin12=PA14
Mcu.Pin13=VP_SYS_VS_Systick
Mcu.Pin14=VP_TIM7_VS_ClockSourceINT
Mcu.Pin10=PA5
Mcu.Pin11=PC4
Mcu.Pin12=PB13
Mcu.Pin13=PA13
Mcu.Pin14=PA14
Mcu.Pin15=VP_SYS_VS_Systick
Mcu.Pin16=VP_TIM7_VS_ClockSourceINT
Mcu.Pin2=PC15-OSC32_OUT
Mcu.Pin3=PF0-OSC_IN
Mcu.Pin4=PF1-OSC_OUT
Mcu.Pin5=PA0
Mcu.Pin6=PA2
Mcu.Pin7=PA3
Mcu.Pin8=PA5
Mcu.Pin9=PC4
Mcu.PinsNb=15
Mcu.Pin5=PC2
Mcu.Pin6=PC3
Mcu.Pin7=PA0
Mcu.Pin8=PA2
Mcu.Pin9=PA3
Mcu.PinsNb=17
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F072RBTx
Expand Down Expand Up @@ -115,6 +117,18 @@ PC14-OSC32_IN.Signal=RCC_OSC32_IN
PC15-OSC32_OUT.Locked=true
PC15-OSC32_OUT.Mode=LSE-External-Oscillator
PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
PC2.GPIOParameters=PinState,GPIO_Label,GPIO_ModeDefaultOutputPP
PC2.GPIO_Label=OUT1
PC2.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_OD
PC2.Locked=true
PC2.PinState=GPIO_PIN_SET
PC2.Signal=GPIO_Output
PC3.GPIOParameters=PinState,GPIO_Label,GPIO_ModeDefaultOutputPP
PC3.GPIO_Label=OUT2
PC3.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_OD
PC3.Locked=true
PC3.PinState=GPIO_PIN_SET
PC3.Signal=GPIO_Output
PC4.Locked=true
PC4.Signal=GPIO_Output
PCC.Checker=false
Expand Down
33 changes: 33 additions & 0 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,29 @@ static void MX_ADC_Init(void);
/* USER CODE END PFP */

/* USER CODE BEGIN 0 */
void actuateOutput(char dtmfcode)
{
switch(dtmfcode){
case '1' :
HAL_GPIO_WritePin(OUT1_GPIO_Port, OUT1_Pin, GPIO_PIN_RESET);
break;

case '2' :
HAL_GPIO_WritePin(OUT1_GPIO_Port, OUT1_Pin, GPIO_PIN_SET);
break;

case '4' :
HAL_GPIO_WritePin(OUT2_GPIO_Port, OUT2_Pin, GPIO_PIN_RESET);
break;

case '5' :
HAL_GPIO_WritePin(OUT2_GPIO_Port, OUT2_Pin, GPIO_PIN_SET);
break;

default:
break;
}
}
/* USER CODE END 0 */

/**
Expand Down Expand Up @@ -164,6 +186,7 @@ int main(void)

if (dail1.new){
printf ("%c ", DTMFchar[dail1.digit & 0x0F]);
actuateOutput(DTMFchar[dail1.digit & 0x0F]);
dail1.new = 0;
}
}
Expand Down Expand Up @@ -345,6 +368,9 @@ static void MX_GPIO_Init(void)
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, OUT1_Pin|OUT2_Pin, GPIO_PIN_SET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);

Expand All @@ -360,6 +386,13 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : OUT1_Pin OUT2_Pin */
GPIO_InitStruct.Pin = OUT1_Pin|OUT2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/*Configure GPIO pin : LD2_Pin */
GPIO_InitStruct.Pin = LD2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
Expand Down

0 comments on commit 97a40be

Please sign in to comment.