Skip to content

Commit

Permalink
- Added DMA module,
Browse files Browse the repository at this point in the history
- Initialised USART6 using DMA,
- Strings receivedd freom GPS are handled using DMA,
- Added an External Interrupt, via button at PA0
  • Loading branch information
abtom87 committed Feb 3, 2018
1 parent f1659ec commit 10a406c
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 101 deletions.
4 changes: 2 additions & 2 deletions inc/comm_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#ifndef COMM_SERVICE_H_
#define COMM_SERVICE_H_


#include "usart2_comm.h"
#include "i2c_lcd.h"
#include <string.h>

void parser_gprmc(char *);

void Display_Time_LCD(char *str_to_parse, char *str_to_extract, const uint8_t ofsset);


#endif /* COMM_SERVICE_H_ */
23 changes: 23 additions & 0 deletions inc/dma2_driver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* dma1_driver.h
*
* Created on: Feb 2, 2018
* Author: abel
*/

#ifndef DMA2_DRIVER_H_
#define DMA2_DRIVER_H_


#include "stm32f4xx_dma.h"

#define DMA2_USART6_STREAM DMA2_Stream2
#define DMA_RX_BUFFER_SIZE 384
uint8_t DMA_RX_Buffer[DMA_RX_BUFFER_SIZE];

void init_dma2(void);

void enable_dma2_irq(void);


#endif /* DMA2_DRIVER_H_ */
3 changes: 3 additions & 0 deletions inc/external_int_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
#include "stm32f4xx.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_it.h"
#include "stm32f4xx_exti.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_syscfg.h"
#include "vector_prio.h"
#include "misc.h"



Expand Down
1 change: 1 addition & 0 deletions inc/gpio_led.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "stm32f4xx.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_it.h"
#include "stm32f4xx_gpio.h"



Expand Down
3 changes: 3 additions & 0 deletions inc/inp_capture.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
#include "stm32f4xx.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_it.h"
#include "stm32f4xx_tim.h"
#include "stm32f4xx_gpio.h"
#include "vector_prio.h"
#include "misc.h"

TIM_ICInitTypeDef Tim1_IC_Struct;
void init_capture_module(void);
Expand Down
3 changes: 1 addition & 2 deletions inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@




void initialiseTimer(void);
void SysTick_Init(void);
void Delay_ms(unsigned long);
Expand All @@ -35,6 +34,6 @@ void enable_Tim_Interrupts(void);



GPIO_InitTypeDef GPIO_InitDef;
//GPIO_InitTypeDef GPIO_InitDef;

#endif /* MAIN_H_ */
2 changes: 2 additions & 0 deletions inc/timer2_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "stm32f4xx.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_it.h"
#include "stm32f4xx_tim.h"
#include "misc.h"
#include "vector_prio.h"


Expand Down
4 changes: 3 additions & 1 deletion inc/usart2_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_it.h"
#include "stm32f4xx_usart.h"
#include "misc.h"
#include "stm32f4xx_gpio.h"
#include "vector_prio.h"
#include <string.h>

volatile uint16_t Recvd_word;
//volatile uint16_t Recvd_word;
void init_usart2_comm_module(void);
void init_usart2_gpio(void);
void enable_usart2_rx_irq(void);
Expand Down
37 changes: 37 additions & 0 deletions inc/usart6_dma_comm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* usart1_dma_comm.h
*
* Created on: Feb 2, 2018
* Author: abel
*/

#ifndef USART6_DMA_COMM_H_
#define USART6_DMA_COMM_H_

#define USART6_GPIO GPIOC


#include "stm32f4xx.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_it.h"
#include "stm32f4xx_usart.h"
#include "misc.h"
#include "stm32f4xx_gpio.h"
#include "vector_prio.h"
#include <string.h>


void init_usart6_comm_module(void);
void init_usart6_gpio(void);
void enable_usart6_rx_irq(void);
void USART6_TX_byte(uint8_t);
void USART6_TX_string(char *);








#endif /* USART6_DMA_COMM_H_ */
33 changes: 33 additions & 0 deletions src/comm_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,36 @@ void parser_gprmc(char *str_to_parse)
USART_TX_byte('\n');

}

void Display_Time_LCD(char *str_to_parse, char *str_to_extract, const uint8_t offset)
{
int k=0;
volatile char *substr;
char Time_buffer[10]={0};
char gps_buffer[1024]={0};

for(int i=0;i<strlen(str_to_parse);i++)
gps_buffer[i] = str_to_parse[i];


substr = strstr(gps_buffer,str_to_extract);
k=offset;
while(k<13)
{
Time_buffer[k-7]=(substr[k]);
k++;
}

if(Time_buffer[1] == 0x39)
{
Time_buffer[1] = 0x30;
Time_buffer[0]+=1;
}
else
Time_buffer[1] += 1;


LCD_Goto(7,1);
LCD_Write_String(Time_buffer);

}
6 changes: 3 additions & 3 deletions src/external_int_button.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void enable_external_button_interrupt(void)
NVIC_InitTypeDef NVIC_EXTINT_Button;
NVIC_EXTINT_Button.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_EXTINT_Button.NVIC_IRQChannelCmd = ENABLE;
NVIC_EXTINT_Button.NVIC_IRQChannelPreemptionPriority = 5;
NVIC_EXTINT_Button.NVIC_IRQChannelPreemptionPriority = PRIO_EXT_INT0;
NVIC_EXTINT_Button.NVIC_IRQChannelSubPriority = 0;

NVIC_Init(&NVIC_EXTINT_Button);
Expand Down Expand Up @@ -46,8 +46,8 @@ void init_external_interrupt(void)
{
EXTI_InitTypeDef EXT_GPIO_InitStruct;
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);


//
//
// SYSCFG_EXTILineConfig(EXTERNAL_BUTTON_PORT,GPIO_Pin_0);
EXT_GPIO_InitStruct.EXTI_Line = EXTI_Line0;
EXT_GPIO_InitStruct.EXTI_LineCmd = ENABLE;
Expand Down
2 changes: 1 addition & 1 deletion src/i2c1_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void init_i2c_bus_config(void)
I2C_InitTypeDef I2C1_InitStruct;

RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
I2C1_InitStruct.I2C_ClockSpeed = 100000;
I2C1_InitStruct.I2C_ClockSpeed = 120000;
I2C1_InitStruct.I2C_Ack = I2C_Ack_Enable;
I2C1_InitStruct.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
I2C1_InitStruct.I2C_Mode = I2C_Mode_I2C;
Expand Down
Loading

0 comments on commit 10a406c

Please sign in to comment.