Skip to content

Commit 10e1d6c

Browse files
author
lin.jia
committed
CM4: Update Code; Seprate Hardware files into different folder; Chassis Main Program (CHASSIS_task) Done - Control with the new CANOpen Protocol
1 parent 036411a commit 10e1d6c

36 files changed

+4588
-1935
lines changed

FreeRTOS-CANOpen-STM32F407/HARDWARE/LED/led.c

Lines changed: 0 additions & 35 deletions
This file was deleted.

FreeRTOS-CANOpen-STM32F407/HARDWARE/LED/led.h

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
******************************************************************************
3+
* @file anticollision.c
4+
* @author Jim
5+
* @version V1.0
6+
* @date 16-Jan-2015
7+
* @brief This file provides anticollision functions
8+
*
9+
******************************************************************************
10+
* @attention
11+
*
12+
* <h2><center>&copy; COPYRIGHT 2015 CSST Robot Research Center</center></h2>
13+
*
14+
******************************************************************************
15+
*/
16+
#include "anticollision.h"
17+
#include "stm32f4xx.h"
18+
19+
20+
void SENSOR_Anticollision(void)
21+
{
22+
23+
}
24+
25+
26+
/****************** (C) COPYRIGHT CSST Robot Research Center *****END OF FILE****/
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
******************************************************************************
3+
* @file anticollision.h
4+
* @author Jim
5+
* @version V1.0
6+
* @date 16-Jan-2015
7+
* @brief This file provides anticollision variable definitions.
8+
*
9+
******************************************************************************
10+
* @attention
11+
*
12+
* <h2><center>&copy; COPYRIGHT 2015 CSST Robot Research Center</center></h2>
13+
*
14+
*
15+
******************************************************************************
16+
*/
17+
18+
#ifndef __ANTICOLLISION_H__
19+
#define __ANTICOLLISION_H__
20+
21+
#include "globalstruct.h"
22+
#include "data.h"
23+
24+
25+
void SENSOR_Anticollision(void);
26+
27+
#endif
28+
29+
/****************** (C) COPYRIGHT CSST Robot Research Center *****END OF FILE****/
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/**
2+
******************************************************************************
3+
* @file force_sensor.c
4+
* @author Jim
5+
* @version V1.0
6+
* @date 16-Jan-2015
7+
* @brief This file provides force_sensor functions
8+
*
9+
******************************************************************************
10+
* @attention
11+
*
12+
* <h2><center>&copy; COPYRIGHT 2015 CSST Robot Research Center</center></h2>
13+
*
14+
******************************************************************************
15+
*/
16+
#include "force_sensor.h"
17+
#include "stm32f4xx.h"
18+
19+
20+
21+
__IO uint16_t ADC3ConvertedValue[8] = {0,0,0,0,0,0,0,0}; // the ADC value of the new force sensors
22+
23+
24+
void SENSOR_Force_Init(void)
25+
{
26+
GPIO_InitTypeDef GPIO_InitStructure;
27+
28+
ADC_InitTypeDef ADC_InitStructure;
29+
ADC_CommonInitTypeDef ADC_CommonInitStructure;
30+
31+
DMA_InitTypeDef DMA_InitStructure;
32+
33+
/* GPIO Config ------------------------------------------------------------------*/
34+
/* Enable GPIOF Clock */
35+
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);
36+
37+
// Configure ADC3 Channel13 pin as analog input for New Force sensors' (1,2,3,4) I/Os
38+
GPIO_StructInit(&GPIO_InitStructure); // Reset init structure, if not it can cause issues...
39+
//ADC3 CH9 CH14 CH15 CH4 CH5 CH6 CH7 CH8
40+
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|
41+
GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10;
42+
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
43+
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
44+
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
45+
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
46+
GPIO_Init(GPIOF, &GPIO_InitStructure);
47+
48+
/* DMA2 Config ------------------------------------------------------------------*/
49+
/* Enable DMA2 Clock */
50+
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
51+
/* DMA2 Stream0 channel0 configuration */
52+
53+
DMA_DeInit(DMA2_Stream1);
54+
55+
DMA_InitStructure.DMA_Channel = DMA_Channel_2;
56+
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC3_DR_ADDRESS;
57+
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&ADC3ConvertedValue;
58+
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
59+
DMA_InitStructure.DMA_BufferSize = 8;
60+
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
61+
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
62+
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
63+
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
64+
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
65+
66+
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
67+
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
68+
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
69+
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
70+
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
71+
DMA_Init(DMA2_Stream1, &DMA_InitStructure);
72+
DMA_Cmd(DMA2_Stream1, ENABLE);
73+
74+
/* ADC Config -------------------------------------------------------------------*/
75+
/* Enable ADC3 Clock */
76+
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC3,ENABLE);
77+
/* ADC Common Init */
78+
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
79+
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div4;
80+
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_1; //
81+
//ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
82+
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_15Cycles;
83+
ADC_CommonInit(&ADC_CommonInitStructure);
84+
85+
/* ADC1 Init */
86+
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
87+
//ADC_InitStructure.ADC_ScanConvMode = DISABLE;
88+
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
89+
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
90+
// gtz02nov ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConvEdge_None;
91+
ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; //gtz01nov
92+
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1;
93+
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
94+
//ADC_InitStructure.ADC_NbrOfConversion = 1;
95+
ADC_InitStructure.ADC_NbrOfConversion = 8;
96+
ADC_Init(ADC3, &ADC_InitStructure);
97+
98+
/* ADC3 regular channelx configuration */
99+
ADC_RegularChannelConfig(ADC3, ADC_Channel_9, 1, ADC_SampleTime_144Cycles);// PF3
100+
ADC_RegularChannelConfig(ADC3, ADC_Channel_14, 2, ADC_SampleTime_144Cycles);// PF4
101+
ADC_RegularChannelConfig(ADC3, ADC_Channel_15, 3, ADC_SampleTime_144Cycles);// PF5
102+
ADC_RegularChannelConfig(ADC3, ADC_Channel_4, 4, ADC_SampleTime_144Cycles);// PF6
103+
ADC_RegularChannelConfig(ADC3, ADC_Channel_5, 5, ADC_SampleTime_144Cycles);// PF7
104+
ADC_RegularChannelConfig(ADC3, ADC_Channel_6, 6, ADC_SampleTime_144Cycles);// PF8
105+
ADC_RegularChannelConfig(ADC3, ADC_Channel_7, 7, ADC_SampleTime_144Cycles);// PF9
106+
ADC_RegularChannelConfig(ADC3, ADC_Channel_8, 8, ADC_SampleTime_144Cycles);// PF10
107+
108+
/* Enable DMA request after last transfer (Single-ADC mode) */
109+
ADC_DMARequestAfterLastTransferCmd(ADC3, ENABLE);//gtz01nov
110+
111+
ADC_ContinuousModeCmd(ADC3, ENABLE);
112+
113+
/* Enable ADC3 DMA */
114+
ADC_DMACmd(ADC3, ENABLE);
115+
116+
/* Enable ADC3 */
117+
ADC_Cmd(ADC3, ENABLE);
118+
119+
/* Start ADC3 Software Conversion */
120+
ADC_SoftwareStartConv(ADC3);
121+
}
122+
123+
/****************** (C) COPYRIGHT CSST Robot Research Center *****END OF FILE****/
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
******************************************************************************
3+
* @file force_sensor.c
4+
* @author Jim
5+
* @version V1.0
6+
* @date 16-Jan-2015
7+
* @brief This file provides force_sensor variable definitions.
8+
*
9+
******************************************************************************
10+
* @attention
11+
*
12+
* <h2><center>&copy; COPYRIGHT 2015 CSST Robot Research Center</center></h2>
13+
*
14+
*
15+
******************************************************************************
16+
*/
17+
18+
#ifndef __FORCE_SENSOR_H__
19+
#define __FORCE_SENSOR_H__
20+
21+
#include "globalstruct.h"
22+
#include "data.h"
23+
24+
25+
#define ADC3_DR_ADDRESS ((uint32_t)0x4001224C)
26+
27+
void SENSOR_Force_Init(void);
28+
29+
#endif
30+
31+
/****************** (C) COPYRIGHT CSST Robot Research Center *****END OF FILE****/
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
******************************************************************************
3+
* @file ir_autocharge.c
4+
* @author Jim
5+
* @version V1.0
6+
* @date 16-Jan-2015
7+
* @brief This file provides ir_autocharge functions
8+
*
9+
******************************************************************************
10+
* @attention
11+
*
12+
* <h2><center>&copy; COPYRIGHT 2015 CSST Robot Research Center</center></h2>
13+
*
14+
******************************************************************************
15+
*/
16+
#include "ir_autocharge.h"
17+
#include "stm32f4xx.h"
18+
19+
AUTO_CHARGE Auto_charge;
20+
21+
void SENSOR_IR_Autocharge_Init(void)
22+
{
23+
GPIO_InitTypeDef GPIO_InitStructure;
24+
NVIC_InitTypeDef NVIC_InitStructure;
25+
EXTI_InitTypeDef EXTI_InitStructure;
26+
27+
/* GPIO Config ------------------------------------------------------------------*/
28+
/* Enable GPIOG Clock */
29+
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);
30+
//EXTI
31+
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;
32+
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; //ÊäÈëģʽ
33+
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //ÉÏÀ­
34+
GPIO_Init(GPIOG, &GPIO_InitStructure);
35+
//EXTI
36+
37+
38+
/* NVIC Config ------------------------------------------------------------------*/
39+
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
40+
41+
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
42+
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
43+
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
44+
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
45+
NVIC_Init(&NVIC_InitStructure);
46+
47+
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;
48+
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
49+
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
50+
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
51+
NVIC_Init(&NVIC_InitStructure);
52+
53+
54+
/* EXTI Config ------------------------------------------------------------------*/
55+
SYSCFG_EXTILineConfig(IRPORT,IRPIN0);
56+
SYSCFG_EXTILineConfig(IRPORT,IRPIN1);
57+
58+
EXTI_InitStructure.EXTI_Line = EXTI_Line0|EXTI_Line1;
59+
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
60+
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
61+
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
62+
EXTI_Init(&EXTI_InitStructure);
63+
}
64+
65+
66+
/****************** (C) COPYRIGHT CSST Robot Research Center *****END OF FILE****/
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
******************************************************************************
3+
* @file ir_autocharge.c
4+
* @author Jim
5+
* @version V1.0
6+
* @date 16-Jan-2015
7+
* @brief This file provides ir_autocharge variable definitions.
8+
*
9+
******************************************************************************
10+
* @attention
11+
*
12+
* <h2><center>&copy; COPYRIGHT 2015 CSST Robot Research Center</center></h2>
13+
*
14+
*
15+
******************************************************************************
16+
*/
17+
18+
#ifndef __IR_AUTOCHARGE_H__
19+
#define __IR_AUTOCHARGE_H__
20+
21+
#include "globalstruct.h"
22+
#include "data.h"
23+
24+
#define IRPIN0 EXTI_PinSource0
25+
#define IRPIN1 EXTI_PinSource1
26+
#define IRPORT EXTI_PortSourceGPIOG
27+
28+
typedef struct
29+
{
30+
u16 Infared0_time,Infared1_time;
31+
u16 Infared0_time_end,Infared1_time_end;
32+
u16 Infared0_collected,Infared1_collected;
33+
u16 receive_status;
34+
u16 nosignal_counting;
35+
36+
u16 Infared0_width,Infared1_width;
37+
38+
}AUTO_CHARGE;
39+
40+
41+
void SENSOR_IR_Autocharge_Init(void);
42+
#endif
43+
44+
/****************** (C) COPYRIGHT CSST Robot Research Center *****END OF FILE****/

0 commit comments

Comments
 (0)