partial success (reverse bit order)

This commit is contained in:
Attila BODY 2018-12-14 17:20:02 +01:00
parent 90e638deab
commit b59a086a82
6 changed files with 295 additions and 201 deletions

View file

@ -41,7 +41,7 @@
#include "gpio.h"
/* USER CODE BEGIN Includes */
#include "bitband.h"
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
@ -99,17 +99,42 @@ int main(void)
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
GPIOB->ODR = 0;
volatile uint32_t v;
uint8_t ledbytes[] = {0x0f, 0xf0, 0};
__disable_irq();
while(1)
{
uint32_t *bitPtr = BITBAND_RAM(ledbytes, 0);
uint32_t cnt = sizeof(ledbytes)*8 + 1;
while(--cnt) {
if(*bitPtr++) {
GPIOB->BSRR = 1 << 11; //set
for( v=5; v != 0; --v); //long
GPIOB->BSRR = 1 << (16+11); //clear
++v; ++v; //short
} else {
GPIOB->BSRR = 1 << 11; //set
for( v=0; v != 0; --v); //short
++v;++v;
GPIOB->BSRR = 1 << (16+11); //clear
for( v=3; v != 0; --v); //long
++v; ++v;
}
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
for( v=400; v != 0; --v); //long
}
/* USER CODE END 3 */
}
static void LL_Init(void)
{
@ -148,39 +173,46 @@ static void LL_Init(void)
void SystemClock_Config(void)
{
LL_FLASH_SetLatency(LL_FLASH_LATENCY_0);
LL_FLASH_SetLatency(LL_FLASH_LATENCY_2);
if(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0)
if(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_2)
{
Error_Handler();
}
LL_RCC_HSI_SetCalibTrimming(16);
LL_RCC_HSE_Enable();
LL_RCC_HSI_Enable();
/* Wait till HSE is ready */
while(LL_RCC_HSE_IsReady() != 1)
{
}
LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE_DIV_1, LL_RCC_PLL_MUL_9);
/* Wait till HSI is ready */
while(LL_RCC_HSI_IsReady() != 1)
LL_RCC_PLL_Enable();
/* Wait till PLL is ready */
while(LL_RCC_PLL_IsReady() != 1)
{
}
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2);
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
/* Wait till System clock is ready */
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI)
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL)
{
}
LL_Init1msTick(8000000);
LL_Init1msTick(72000000);
LL_SYSTICK_SetClkSource(LL_SYSTICK_CLKSOURCE_HCLK);
LL_SetSystemCoreClock(8000000);
LL_SetSystemCoreClock(72000000);
/* SysTick_IRQn interrupt configuration */
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));