Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 2:d45b3a0f19a2, committed 2017-09-02
- Comitter:
- y2kb
- Date:
- Sat Sep 02 06:56:21 2017 +0000
- Parent:
- 1:adb29fbb0d8d
- Commit message:
- Reduce CPU clock dependent part so that it can correspond to various boards
Changed in this revision
--- a/Inc/main.h Fri Sep 01 15:32:42 2017 +0000 +++ b/Inc/main.h Sat Sep 02 06:56:21 2017 +0000 @@ -57,6 +57,7 @@ /* USER CODE END Includes */ /* Private define ------------------------------------------------------------*/ +#define TIM_CLOCK_SOURCE_HZ 100000000 #define B1_Pin GPIO_PIN_13 #define B1_GPIO_Port GPIOC @@ -101,7 +102,11 @@ /* USER CODE BEGIN Private defines */ #define FreeRTOS_PERIOD_HZ 20000 -#define I2C_CLOCK_SPEED 400000 + +#ifdef TIM_CLOCK_SOURCE_HZ +#undef TIM_CLOCK_SOURCE_HZ +#define TIM_CLOCK_SOURCE_HZ (SystemCoreClock/1) +#endif extern void _Error_Handler(char *, int); extern void MX_FREERTOS_Init(void);
--- a/Src/RotaryEncoder_AS5600.c Fri Sep 01 15:32:42 2017 +0000
+++ b/Src/RotaryEncoder_AS5600.c Sat Sep 02 06:56:21 2017 +0000
@@ -69,13 +69,10 @@
*/
void initEncoder(void)
{
+ HAL_StatusTypeDef status;
+ uint8_t AS5600_status;
AS5600_init_start:
- assert_param(AS5600_hi2c.Init.ClockSpeed == I2C_CLOCK_SPEED);
-
- HAL_StatusTypeDef status;
-
// Read AS5600 status register
- uint8_t AS5600_status;
status = HAL_I2C_Mem_Read(&AS5600_hi2c, AS5600_DEV_ADDRESS, AS5600_REG_STATUS,
I2C_MEMADD_SIZE_8BIT, &AS5600_status, 1, AS5600_I2C_TIMEOUT_MS);
if (status != HAL_OK) {
--- a/Src/tim.c Fri Sep 01 15:32:42 2017 +0000
+++ b/Src/tim.c Sat Sep 02 06:56:21 2017 +0000
@@ -64,7 +64,7 @@
htim3.Instance = TIM3;
htim3.Init.Prescaler = 0;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
- htim3.Init.Period = 4999;
+ htim3.Init.Period = TIM_CLOCK_SOURCE_HZ / 20000 - 1;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
{
@@ -162,4 +162,3 @@
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-