Skip to content

Commit

Permalink
Interim STM32f030 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
deece committed Nov 23, 2016
1 parent d6ca134 commit 2d2c4d9
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 2 deletions.
59 changes: 57 additions & 2 deletions hw/cortexm/stm32-mcus.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,51 @@
* I = 2048K
*/

static const STM32Capabilities stm32f030x8 = {

.family = STM32_FAMILY_F0,

.hsi_freq_hz = 8000000,
.lsi_freq_hz = 40000,
.has_rcc = true,
.has_pwr = true,
.has_rtc = true,
.num_back_bytes = 20,
.has_periph_bitband = true,

.has_crc = true,
.has_exti = true,
.has_dma1 = true,
.num_dma1 = 7,
.has_ac_tim1 = true,
.has_gp_tim2 = true,
.has_gp_tim3 = true,
.has_gp_tim4 = true,
.has_iwdg = true,
.has_wwdg = true,
.has_i2c1 = true,
.has_i2c2 = true,
#if 0
.has_usart1 = true, /* 4.5Mb/s */
.has_usart2 = true, /* 2.25 Mb/s */
.has_usart3 = true, /* 2.25 Mb/s */
#endif
.has_spi1 = true,
.has_spi2 = true,
.has_usb_fs = true,

.has_gpioa = true,
.has_gpiob = true,
.has_gpioc = true,
.has_gpiod = true,
.has_gpioe = true,

.has_adc1 = true, /* 12-bits, 16-ch */
.has_adc2 = true, /* 12-bits, 16-ch */

.has_ts = 1, /* ADC12_IN16 */
};

static const STM32Capabilities stm32f103x8b = {

.family = STM32_FAMILY_F1,
Expand Down Expand Up @@ -582,13 +627,14 @@ static const STM32Capabilities stm32f429xx = {

/* ------------------------------------------------------------------------- */

#if 0
static const CortexMCoreCapabilities stm32f0xx_core = {
.cpu_model = "cortex-m0",
.has_mpu = false, /* itm? irqs? */
.has_mpu = false, /* itm? */
.num_irq = 32,
.nvic_bits = 4, /**/
};

#if 0
static const CortexMCoreCapabilities stm32f100_core = {
.cpu_model = "cortex-m3",
.has_mpu = true,
Expand Down Expand Up @@ -692,6 +738,15 @@ static const STM32PartInfo stm32_mcus[] = {
}, /**/
},
#endif
{
.name = TYPE_STM32F030R8,
.cortexm = {
.flash_size_kb = 64,
.sram_size_kb = 8,
.core = &stm32f0xx_core, /**/
},
.stm32 = &stm32f030x8, /**/
},
{
.name = TYPE_STM32F103RB, /* STM32F103x[8B] */
.cortexm = {
Expand Down
55 changes: 55 additions & 0 deletions hw/cortexm/stm32-nucleo-boards.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,60 @@
* This file defines several STM32 Nucleo boards.
*/

/* ----- ST NUCLEO-F030R8 ----- */

static GPIOLEDInfo nucleo_f030r8_leds_info[] = {
{
.name = "green-led",
.active_low = false,
.colour_message = "Green",
.x = 277,
.y = 271,
.w = 8,
.h = 6,
.gpio_path = "/machine/mcu/stm32/gpio[a]",
.port_bit = 5, },
{ }, /**/
};

static void nucleo_f030r8_board_init_callback(MachineState *machine)
{
CortexMBoardState *board = CORTEXM_BOARD_STATE(machine);

cortexm_board_greeting(board);

{
/* Create the MCU */
Object *mcu = cm_object_new_mcu(machine, TYPE_STM32F030R8);

/* The board has no oscillators. */
cm_object_property_set_int(mcu, 0, "hse-freq-hz"); /* N/A */
cm_object_property_set_int(mcu, 0, "lse-freq-hz"); /* N/A */

cm_object_realize(mcu);
}

cortexm_board_init_graphic_image(board, "NUCLEO-F103RB.jpg");

Object *peripheral = cm_container_get_peripheral();
gpio_led_create_from_info(peripheral, nucleo_f030r8_leds_info,
&(board->graphic_context));
}

static void nucleo_f030r8_board_class_init_callback(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);

mc->desc = "ST Nucleo Development Board for STM32 F0 series";
mc->init = nucleo_f030r8_board_init_callback;
}

static const TypeInfo nucleo_f030r8_machine = {
.name = BOARD_TYPE_NAME("NUCLEO-F030R8"),
.parent = TYPE_CORTEXM_BOARD,
.class_init = nucleo_f030r8_board_class_init_callback };


/* ----- ST NUCLEO-F103RB ----- */

static GPIOLEDInfo nucleo_f103rb_leds_info[] = {
Expand Down Expand Up @@ -170,6 +224,7 @@ static void nucleo_f334r8_board_init_callback(MachineState *machine)
/* ----- Boards inits ----- */
static void stm32_machines_init(void)
{
type_register_static(&nucleo_f030r8_machine);
type_register_static(&nucleo_f103rb_machine);
type_register_static(&nucleo_f411re_machine);
#if 0
Expand Down
1 change: 1 addition & 0 deletions include/hw/cortexm/stm32-mcus.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* For compatibility with some development tools, it is
* strongly recommended to use the CMSIS names.
*/
#define TYPE_STM32F030R8 "STM32F030R8"
#define TYPE_STM32F051R8 "STM32F051R8"
#define TYPE_STM32F100RB "STM32F100RB"
#define TYPE_STM32F103RB "STM32F103RB"
Expand Down

0 comments on commit 2d2c4d9

Please sign in to comment.