Nathan Petersen
Published © CERN-OHL

Razzler: POV LED Toy Top

A toy top based on an STM32F0 that uses an accelerometer to display POV animations on a line of LEDs as it spins!

IntermediateFull instructions provided5 hours764
Razzler: POV LED Toy Top

Things used in this project

Hardware components

STM32F0
×1
MPU-6050
×1
MBI5024
×1

Hand tools and fabrication machines

Hot air reflow

Story

Read more

Schematics

PDF of schematics and layout

Code

Main function that runs Razzler

C/C++
#include "defines.h"
#include "scheduler.h"
#include "animator.h"
#include "dmp.h"
#include "motion.h"
#include "orientation.h"
#include "power.h"

// Board hardware elements
#include "status_led.h"
#include "mbi5024.h"
#include "mpu6050.h"

void init_clock(void)
{
	// Set up 48 MHz Core Clock using HSI (8Mhz) with PLL x 6 (must do x12 to get 48MHz...?)
	RCC_PLLConfig(RCC_PLLSource_HSI, RCC_PLLMul_12);
	RCC_PLLCmd(ENABLE);

	// Wait for PLLRDY after enabling PLL.
	while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) != SET);

	// Select the PLL as clock source.
	RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

	SystemCoreClockUpdate();
}

void board_hw_init(void)
{
	init_clock();

	// Initialize status LED (defaults to off)
	status_led_init();

	// Initialize MBI5024 interface
	mbi5024_init();

	// Initialize MPU-6050 interface
	mpu6050_init();
}

int main(int argc, char* argv[])
{
	UNUSED(argc);
	UNUSED(argv);

	// initialize the board hardware
	board_hw_init();

	// initialize the animator module
	animator_task_init();

	// initialize the DMP stack
	dmp_scheduler_task_init();
	orientation_dmp_task_init();
	motion_dmp_task_init();

	// initialize the power manager
	power_task_init();

	// initialize scheduler, and run it
	// NOTE: on run, it takes over and never returns...
	scheduler_init();
	scheduler_run();

	return 0;
}

Credits

Nathan Petersen

Nathan Petersen

3 projects • 0 followers
Current student in Computer Science with an emphasis on Embedded Systems at UW-Madison. Read about my personal projects: nathanpetersen.com

Comments