kopia lustrzana https://github.com/Schildkroet/GRBL-Advanced
Cleaned up sources
rodzic
3ea40e5753
commit
edc39d217c
|
@ -54,38 +54,6 @@ extern void Limit_PinChangeISR(void);
|
||||||
extern void System_PinChangeISR(void);
|
extern void System_PinChangeISR(void);
|
||||||
|
|
||||||
|
|
||||||
void SysTick_Init(void)
|
|
||||||
{
|
|
||||||
RCC_ClocksTypeDef RCC_Clocks;
|
|
||||||
|
|
||||||
/* SysTick end of count event each 1ms */
|
|
||||||
RCC_GetClocksFreq(&RCC_Clocks);
|
|
||||||
SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
|
|
||||||
|
|
||||||
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 5));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// for 100 MHz STM32F411
|
|
||||||
#define COUNTS_PER_MICROSECOND 33
|
|
||||||
void Delay_us(volatile uint32_t us)
|
|
||||||
{
|
|
||||||
volatile uint32_t count = us * COUNTS_PER_MICROSECOND - 2;
|
|
||||||
__asm volatile(" mov r0, %[count] \n\t"
|
|
||||||
"1: subs r0, #1 \n\t"
|
|
||||||
" bhi 1b \n\t"
|
|
||||||
:
|
|
||||||
: [count] "r" (count)
|
|
||||||
: "r0");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Delay_ms(volatile uint32_t ms)
|
|
||||||
{
|
|
||||||
while(ms--)
|
|
||||||
Delay_us(999);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* Cortex-M4 Processor Exceptions Handlers */
|
/* Cortex-M4 Processor Exceptions Handlers */
|
||||||
|
|
|
@ -42,10 +42,6 @@
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
/* Exported functions ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
void SysTick_Init(void);
|
|
||||||
void Delay_us(volatile uint32_t us);
|
|
||||||
void Delay_ms(volatile uint32_t ms);
|
|
||||||
|
|
||||||
void NMI_Handler(void);
|
void NMI_Handler(void);
|
||||||
void HardFault_Handler(void);
|
void HardFault_Handler(void);
|
||||||
void MemManage_Handler(void);
|
void MemManage_Handler(void);
|
||||||
|
|
|
@ -15,6 +15,37 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with STM32F4_HAL. If not, see <http://www.gnu.org/licenses/>.
|
along with STM32F4_HAL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "system.h"
|
#include "System32.h"
|
||||||
|
|
||||||
|
|
||||||
|
void SysTick_Init(void)
|
||||||
|
{
|
||||||
|
RCC_ClocksTypeDef RCC_Clocks;
|
||||||
|
|
||||||
|
/* SysTick end of count event each 1ms */
|
||||||
|
RCC_GetClocksFreq(&RCC_Clocks);
|
||||||
|
SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
|
||||||
|
|
||||||
|
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 5));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// for 100 MHz STM32F411
|
||||||
|
#define COUNTS_PER_MICROSECOND 33
|
||||||
|
void Delay_us(volatile uint32_t us)
|
||||||
|
{
|
||||||
|
volatile uint32_t count = us * COUNTS_PER_MICROSECOND - 2;
|
||||||
|
__asm volatile(" mov r0, %[count] \n\t"
|
||||||
|
"1: subs r0, #1 \n\t"
|
||||||
|
" bhi 1b \n\t"
|
||||||
|
:
|
||||||
|
: [count] "r" (count)
|
||||||
|
: "r0");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Delay_ms(volatile uint32_t ms)
|
||||||
|
{
|
||||||
|
while(ms--)
|
||||||
|
Delay_us(999);
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,12 @@ typedef struct {
|
||||||
} Date_t;
|
} Date_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void SysTick_Init(void);
|
||||||
|
void Delay_us(volatile uint32_t us);
|
||||||
|
void Delay_ms(volatile uint32_t ms);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
/*
|
||||||
|
FIFO_USART.c - FIFO USART Implementation
|
||||||
|
Part of STM32F4_HAL
|
||||||
|
|
||||||
|
Copyright (c) 2016-2017 Patrick F.
|
||||||
|
|
||||||
|
STM32F4_HAL is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
STM32F4_HAL is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with STM32F4_HAL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
/* Very simple queue
|
/* Very simple queue
|
||||||
* These are FIFO queues which discard the new data when full.
|
* These are FIFO queues which discard the new data when full.
|
||||||
*
|
*
|
||||||
|
@ -8,7 +26,7 @@
|
||||||
* Queue is full when in == (out-1 + QUEUE_SIZE) % QUEUE_SIZE;
|
* Queue is full when in == (out-1 + QUEUE_SIZE) % QUEUE_SIZE;
|
||||||
*
|
*
|
||||||
* The queue will hold QUEUE_ELEMENTS number of items before the
|
* The queue will hold QUEUE_ELEMENTS number of items before the
|
||||||
* calls to QueuePut fail.
|
* calls to FifoUsart_Insert fail.
|
||||||
*/
|
*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "FIFO_USART.h"
|
#include "FIFO_USART.h"
|
||||||
|
|
|
@ -1,3 +1,20 @@
|
||||||
|
/*
|
||||||
|
FIFO_USART.h - FIFO USART Header
|
||||||
|
Part of STM32F4_HAL
|
||||||
|
|
||||||
|
Copyright (c) 2016-2017 Patrick F.
|
||||||
|
|
||||||
|
STM32F4_HAL is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
STM32F4_HAL is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with STM32F4_HAL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#ifndef FIFO_H_INCLUDED
|
#ifndef FIFO_H_INCLUDED
|
||||||
#define FIFO_H_INCLUDED
|
#define FIFO_H_INCLUDED
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Usart.c - Usart implementation
|
USART.c - USART implementation
|
||||||
Part of STM32F4_HAL
|
Part of STM32F4_HAL
|
||||||
|
|
||||||
Copyright (c) 2017 Patrick F.
|
Copyright (c) 2017 Patrick F.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Usart.h - Usart Header
|
USART.h - USART Header
|
||||||
Part of STM32F4_HAL
|
Part of STM32F4_HAL
|
||||||
|
|
||||||
Copyright (c) 2017 Patrick F.
|
Copyright (c) 2017 Patrick F.
|
||||||
|
|
Ładowanie…
Reference in New Issue