kopia lustrzana https://github.com/Schildkroet/GRBL-Advanced
Some more clean up etc
rodzic
edc39d217c
commit
4c0fa77006
|
@ -1,11 +1,8 @@
|
|||
#include "stm32f4xx_exti.h"
|
||||
#include "EXTI.h"
|
||||
#include "stm32f4xx_conf.h"
|
||||
|
||||
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static void Exti_RFM22B_RecvPacket(void);
|
||||
|
||||
|
||||
|
||||
void Exti_Init0(uint8_t preemp_prio, uint8_t sub_prio)
|
||||
|
@ -15,64 +12,45 @@ void Exti_Init0(uint8_t preemp_prio, uint8_t sub_prio)
|
|||
(void)sub_prio;
|
||||
}
|
||||
|
||||
|
||||
void Exti_Init1(uint8_t preemp_prio, uint8_t sub_prio)
|
||||
{
|
||||
(void)preemp_prio;
|
||||
(void)sub_prio;
|
||||
}
|
||||
|
||||
|
||||
void Exti_Init2(uint8_t preemp_prio, uint8_t sub_prio)
|
||||
{
|
||||
(void)preemp_prio;
|
||||
(void)sub_prio;
|
||||
}
|
||||
|
||||
|
||||
void Exti_Init3(uint8_t preemp_prio, uint8_t sub_prio)
|
||||
{
|
||||
(void)preemp_prio;
|
||||
(void)sub_prio;
|
||||
}
|
||||
|
||||
|
||||
void Exti_Init4(uint8_t preemp_prio, uint8_t sub_prio)
|
||||
{
|
||||
(void)preemp_prio;
|
||||
(void)sub_prio;
|
||||
}
|
||||
|
||||
|
||||
// External interrupt for line 5 to 9
|
||||
void Exti_Init9_5(uint8_t preemp_prio, uint8_t sub_prio)
|
||||
{
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
|
||||
// Enable and set EXTI9_5 Interrupt
|
||||
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = preemp_prio;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = sub_prio;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
|
||||
Exti_RFM22B_RecvPacket();
|
||||
(void)preemp_prio;
|
||||
(void)sub_prio;
|
||||
}
|
||||
|
||||
|
||||
void Exti_Init15_10(uint8_t preemp_prio, uint8_t sub_prio)
|
||||
{
|
||||
(void)preemp_prio;
|
||||
(void)sub_prio;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------//
|
||||
|
||||
static void Exti_RFM22B_RecvPacket(void)
|
||||
{
|
||||
EXTI_InitTypeDef EXTI_InitStructure;
|
||||
|
||||
// Connect EXTI8 Line to PC8 pin
|
||||
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, GPIO_PinSource8);
|
||||
|
||||
// Configure EXTI8 line
|
||||
EXTI_InitStructure.EXTI_Line = EXTI_Line8;
|
||||
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
|
||||
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&EXTI_InitStructure);
|
||||
}
|
||||
|
|
|
@ -142,11 +142,13 @@ void Spi_Init(SPI_TypeDef *SPIx, SPI_Mode mode)
|
|||
SPI_Cmd(SPIx, ENABLE);
|
||||
}
|
||||
|
||||
|
||||
uint8_t Spi_ReadByte(SPI_TypeDef *SPIx)
|
||||
{
|
||||
return Spi_WriteByte(SPIx, 0xFF);
|
||||
}
|
||||
|
||||
|
||||
uint8_t Spi_WriteByte(SPI_TypeDef *SPIx, uint8_t _data)
|
||||
{
|
||||
// Loop while DR register is not empty
|
||||
|
|
|
@ -242,9 +242,25 @@ void EXTI9_5_IRQHandler(void)
|
|||
void USART1_IRQHandler(void)
|
||||
{
|
||||
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) {
|
||||
/* Read one byte from the receive data register */
|
||||
unsigned char c = (USART_ReceiveData(USART1) & 0xFF);
|
||||
|
||||
// Write character to buffer
|
||||
FifoUsart_Insert(USART1_NUM, USART_DIR_RX, c);
|
||||
}
|
||||
|
||||
if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET) {
|
||||
char c;
|
||||
|
||||
if(FifoUsart_Get(USART1_NUM, USART_DIR_TX, &c) == 0) {
|
||||
/* Write one byte to the transmit data register */
|
||||
while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
|
||||
USART_SendData(USART1, c);
|
||||
}
|
||||
else {
|
||||
// Nothing to transmit - disable interrupt
|
||||
USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
/* If overrun condition occurs, clear the ORE flag and recover communication */
|
||||
|
|
|
@ -31,6 +31,11 @@ void TIM_Init(void)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Timer 1
|
||||
* Outputs ~10 KHz on D11
|
||||
* Used for Variable Spindle PWM
|
||||
**/
|
||||
void Timer1_Init(void)
|
||||
{
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
|
@ -64,6 +69,14 @@ void Timer1_Init(void)
|
|||
TIM_CtrlPWMOutputs(TIM1, ENABLE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Timer 9
|
||||
* Base clock: 20 MHz
|
||||
* Used for Stepper Interrupt
|
||||
* On CC1, Main Stepper Interuppt is called
|
||||
* On Update, Stepper Port Reset is called
|
||||
**/
|
||||
void Timer9_Init(void)
|
||||
{
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
|
|
Ładowanie…
Reference in New Issue