First pass at a BluePill Variant

The official STMicroelectronics Arduino core
User avatar
Rick Kimball
Posts: 728
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: First pass at a BluePill Variant

Postby Rick Kimball » Sun Sep 18, 2016 9:34 pm

i dont't think analog functions will work
-rick

User avatar
RogerClark
Posts: 5466
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: First pass at a BluePill Variant

Postby RogerClark » Sun Sep 18, 2016 9:49 pm

Rick

OK.

Thanks.

I just took a quick look at the pin declarations in variant.cpp and see you defined PC13.

I wonder why they had the "Arduino_id" in the pin map

Code: Select all

typedef struct _PinDescription
{
  uint32_t arduino_id;
  uint32_t ulPin ;
  GPIO_TypeDef  * ulPort;
  uint32_t mode;
  bool configured;
} PinDescription ;


I presume that all we need to do is

Code: Select all

extern const PinDescription g_APinDescription[]=

//  arduino_id  |     ulPin    |   ulPort | mode               |          configured
{
  { PA0,   GPIO_PIN_0,  GPIOA, GPIO_PIN_IO|GPIO_PIN_ADC ,                    false },
  { PA1,   GPIO_PIN_1,  GPIOA, GPIO_PIN_IO|GPIO_PIN_ADC ,                    false },
  { PA2,   GPIO_PIN_2,  GPIOA, GPIO_PIN_IO|GPIO_PIN_UART_TX ,                false },
  { PA3,   GPIO_PIN_3,  GPIOA, GPIO_PIN_IO|GPIO_PIN_UART_RX ,                false },
  { PA4,   GPIO_PIN_4,  GPIOA, GPIO_PIN_IO|GPIO_PIN_ADC ,                    false },
  { PA5,   GPIO_PIN_5,  GPIOA, GPIO_PIN_IO|GPIO_PIN_SPI_SCK,                 false },
  { PA6,   GPIO_PIN_6,  GPIOA, GPIO_PIN_IO|GPIO_PIN_SPI_MISO ,               false },
  { PA7,   GPIO_PIN_7,  GPIOA, GPIO_PIN_IO|GPIO_PIN_SPI_MOSI|GPIO_PIN_PWM,   false },
  { PA8,   GPIO_PIN_8,  GPIOA, GPIO_PIN_IO,                                  false },
  { PA9,   GPIO_PIN_9,  GPIOA, GPIO_PIN_IO,                                  false },
  { PA10,   GPIO_PIN_10, GPIOA, GPIO_PIN_IO,                                  false },
  { PA11,   GPIO_PIN_11, GPIOA, GPIO_PIN_MORPHO_ONLY,                         false },
  { PA12,   GPIO_PIN_12, GPIOA, GPIO_PIN_MORPHO_ONLY,                         false },
  { PA13,   GPIO_PIN_13, GPIOA, GPIO_PIN_MORPHO_ONLY,                         false },
  { PA14,   GPIO_PIN_14, GPIOA, GPIO_PIN_MORPHO_ONLY,                         false },
  { PA15,   GPIO_PIN_15, GPIOA, GPIO_PIN_MORPHO_ONLY ,                        false },
  { PB0,   GPIO_PIN_0,  GPIOB, GPIO_PIN_ADC,                                 false },
  { PB1,   GPIO_PIN_1,  GPIOB, GPIO_PIN_MORPHO_ONLY,                         false },
  { PB2,   GPIO_PIN_2,  GPIOB, GPIO_PIN_MORPHO_ONLY,                         false },
  { PB3,   GPIO_PIN_3,  GPIOB, GPIO_PIN_IO|GPIO_PIN_PWM,                     false },
  { PB4,   GPIO_PIN_4,  GPIOB, GPIO_PIN_IO|GPIO_PIN_PWM,                     false },
  { PB5,   GPIO_PIN_5,  GPIOB, GPIO_PIN_IO,                                  false },
  { PB6,   GPIO_PIN_6,  GPIOB, GPIO_PIN_IO|GPIO_PIN_PWM|GPIO_PIN_SPI_CS,     false },
  { PB7,   GPIO_PIN_7,  GPIOB, GPIO_PIN_MORPHO_ONLY,                         false },
  { PB8,   GPIO_PIN_8,  GPIOB, GPIO_PIN_IO|GPIO_PIN_I2C_SCL,                 false },
  { PB9,   GPIO_PIN_9,  GPIOB, GPIO_PIN_IO|GPIO_PIN_I2C_SDA,                 false },
  { PB10,   GPIO_PIN_10, GPIOB, GPIO_PIN_IO|GPIO_PIN_PWM,                     false },
  { PB11,   GPIO_PIN_11, GPIOB, GPIO_PIN_MORPHO_ONLY,                         false },
  { PB12,   GPIO_PIN_12, GPIOB, GPIO_PIN_MORPHO_ONLY,                         false },
  { PB13,   GPIO_PIN_13, GPIOB, GPIO_PIN_MORPHO_ONLY,                         false },
  { PB14,     GPIO_PIN_14, GPIOB, GPIO_PIN_MORPHO_ONLY,                         false },
  { PB15,     GPIO_PIN_15, GPIOB, GPIO_PIN_MORPHO_ONLY,                         false },
  { PC13,   GPIO_PIN_13, GPIOC, GPIO_PIN_IO,                                  false },
  { PC14,     GPIO_PIN_14, GPIOC, GPIO_PIN_MORPHO_ONLY,                         false },
  { PC15,     GPIO_PIN_15, GPIOC, GPIO_PIN_MORPHO_ONLY,                         false }
} ;



Edit.

Isnt the F103RB basically the same as the F103Cx just in a bigger package.

Perhaps not all of the pins are broken out to the package of the MCU

I didnt think the Anlogue pins would be different.

So perhaps we need to remove pins from this pinmap

Edit

I've done that now

User avatar
RogerClark
Posts: 5466
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: First pass at a BluePill Variant

Postby RogerClark » Sun Sep 18, 2016 10:53 pm

Re: Analog

I see what you mean

There are some pins e.a. PA6, PA7 etc that could have ADC but the "mode" doesnt have ADC specified for those pins

But I can't find anything in the code which actually uses the definition GPIO_PIN_ADC

The only "modes" that seem to be actively used in the code are GPIO_PIN_PWM and GPIO_PIN_DAC , albeit, I'm only looking in the F1 (but as they are self contained cores, thats all that matters.


Edit

I noticed you'bve changed the MAX_DIGITAL_IOS

And I've noticed that we'd need to change any reference to ARDUINO_PIN_xx as I've removed them and replaced with the Pxx definitions

Edit 2

I think the best thing to do is for me to pull to a new branch and then make those changes. @slammer etc can then test that branch before its merged back into the master

User avatar
Slammer
Posts: 241
Joined: Tue Mar 01, 2016 10:35 pm
Location: Athens, Greece

Re: First pass at a BluePill Variant

Postby Slammer » Sun Sep 18, 2016 11:36 pm

ARDUINO_PINS are the corresponding pins on NUCLEO boards (they have arduino uno pinout). They are used just for compatibility with arduino programs (when it is possible). In blue pill they are not needed as there is no relation with arduino numbering. It is better to keep the standard STM32 pin namming (PA1, PA2, PA3 etc...) and if a variant has "arduino pins" to make some extra defines for this.
For example it is possible to keep a predefined type of numbering eg:

PA0 = Port A, Pin 0 = Number 0x00
PA1 = Port A, Pin 1 = Number 0x01
.
.
PB0 = Port B, Pin 0 = Number 0x10
PB1 = Port B, Pin 1 = Number 0x11

First Nibble = Port
Second Nibble = Pin Number
This scheme would be useful as the number of the pin, keeps info about port and pin position (this will help to optimise some functions and/or reduce the size of some structures)

User avatar
RogerClark
Posts: 5466
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: First pass at a BluePill Variant

Postby RogerClark » Mon Sep 19, 2016 12:07 am

@slammer

The PIN_ARDUINO_XXX seems to be used in some other macro's in the same file, so it will all need to be updated for the BluePill etc

I'm busy with work this morning, but I"ll pull Ricks changes to a new branch of the Arduino_Core_STM32F1 repo, this afternoon (or evening), and try to change everything in variant.c, so that tomorrow you guys can give it a try.

Note. We need to get USB Serial working as well.

I know @Vassilis got it working with the HAL MX core that @sheepdoll created, so I'm hoping we can re-used or leverage a lot of his code.

(Though we may also need to re-export the HAL code from the Cube, as I'm not sure whether all the necessary HAL functions were exported as the were not required for the Nucleo board :-(

evge.05
Posts: 11
Joined: Sat Aug 20, 2016 1:46 pm
Location: Russia

Re: First pass at a BluePill Variant

Postby evge.05 » Mon Sep 19, 2016 5:04 am

Hello! Try to use button on PC13. But sketch doesn't compile. Whith Rogers core every thing is fine, but whith this core some things is wrong. As I understand here we can use only arduino pins A0-A5, D0-D15? Port C not defined in this core? Am I right?

User avatar
RogerClark
Posts: 5466
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: First pass at a BluePill Variant

Postby RogerClark » Mon Sep 19, 2016 5:17 am

Rick defined PC13 but I only tried it for output, there may be something else in the code that prevents it from being used as an input

evge.05
Posts: 11
Joined: Sat Aug 20, 2016 1:46 pm
Location: Russia

Re: First pass at a BluePill Variant

Postby evge.05 » Mon Sep 19, 2016 7:40 am

Code: Select all

HAL_GPIO:5: error: 'PC13' was not declared in this scope

that's error.

User avatar
RogerClark
Posts: 5466
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: First pass at a BluePill Variant

Postby RogerClark » Mon Sep 19, 2016 7:44 am

Which core are you using? The one in Rick's repo ?

evge.05
Posts: 11
Joined: Sat Aug 20, 2016 1:46 pm
Location: Russia

Re: First pass at a BluePill Variant

Postby evge.05 » Mon Sep 19, 2016 7:49 am

Yes. On Your core same sketch compiling and working.


Return to “STM Core”

Who is online

Users browsing this forum: No registered users and 1 guest