Skip to content

STM32F1 merged (replaced by #61) #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
68cb5f2
NUCLEO-F103RB added.
Jun 22, 2017
5481b4e
uart, analog(ADC, PWM), digital validated.
Jun 22, 2017
9096864
Moving F1 to keep alphabetical order when Arduino displays names
Jun 22, 2017
2c84fba
Interrupt functions validated
Jun 23, 2017
9b24864
EEPROM validated
Jun 26, 2017
c0beef4
SPI functions validated
Jun 27, 2017
0eaa4b7
I2C functions validated
Jun 27, 2017
87515a6
Removed emulation uart pin because can't be used currently.
Jun 28, 2017
ae3c0d6
Aligns configuration with master
Jun 28, 2017
5d1568d
BluePill F103C8 variant added.
Jun 28, 2017
1502e66
DISCO_F100RB (STM32VLDiscovery) added.
Jun 29, 2017
d7e5ff8
Maple Mini STM32F103CB added.
Jun 29, 2017
b3d9dff
DAC1 replaced by DAC and timer IRQ definitions moved to the right place
Jun 30, 2017
c11863e
Aligns configuration with master
Jun 30, 2017
4e41cd1
Fixes compilation error with Maple mini board
Jun 30, 2017
80fbf70
STM32F1xx flag reordered
Jun 30, 2017
1182fd5
Fixes compilation error: Error_Handler do not exist any more
Jun 30, 2017
bd70f52
Fixes issue on ADC value: calibration function wasn't called
Jul 3, 2017
bec19f1
Aligns configuration of variant Nucleo-F103RB
Jul 3, 2017
dcae4b8
Extra include path moved to the right place
Jul 3, 2017
0df6642
Tab replaced by space
Jul 3, 2017
ab26c43
BluePill pin mapping reordered
Jul 3, 2017
e23f252
Fix warning for unused variable
fpistm Jul 5, 2017
5894c10
Align commented lines
fpistm Jul 5, 2017
3ffb5fd
Fix for firmata
fpistm Jul 5, 2017
2130c91
Use F_CPU defined in board.txt
Jul 6, 2017
dbb5571
Fix size in boards.txt for Nucleo F103RB
fpistm Jul 5, 2017
1bcfddd
Allow VECT_TAB_OFFSET to be override
Jul 6, 2017
295c668
Add USB IRQHandler for BluePill and MapleMini variants
Jul 6, 2017
a81b1e3
Update boards configuration with the new menu
Jul 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ Nucleo_64.menu.board_part_num.NUCLEO_F091RC.build.product_line=STM32F091xC
Nucleo_64.menu.board_part_num.NUCLEO_F091RC.build.variant=NUCLEO_F091RC
Nucleo_64.menu.board_part_num.NUCLEO_F091RC.build.cmsis_lib_gcc=arm_cortexM0l_math

# NUCLEO_F103RB board
# Support: Serial1 (USART1 on PA10, PA9) and Serial2 (USART3 on PC11, PC10)
Nucleo_64.menu.board_part_num.NUCLEO_F103RB=Nucleo F103RB
Nucleo_64.menu.board_part_num.NUCLEO_F103RB.node="NODE_F103RB,NUCLEO"
Nucleo_64.menu.board_part_num.NUCLEO_F103RB.upload.maximum_size=131072
Nucleo_64.menu.board_part_num.NUCLEO_F103RB.upload.maximum_data_size=20480
Nucleo_64.menu.board_part_num.NUCLEO_F103RB.build.mcu=cortex-m3
Nucleo_64.menu.board_part_num.NUCLEO_F103RB.build.f_cpu=72000000L
Nucleo_64.menu.board_part_num.NUCLEO_F103RB.build.board=NUCLEO_F103RB
Nucleo_64.menu.board_part_num.NUCLEO_F103RB.build.series=STM32F1xx
Nucleo_64.menu.board_part_num.NUCLEO_F103RB.build.product_line=STM32F103xB
Nucleo_64.menu.board_part_num.NUCLEO_F103RB.build.variant=NUCLEO_F103RB
Nucleo_64.menu.board_part_num.NUCLEO_F103RB.build.cmsis_lib_gcc=arm_cortexM3l_math

# NUCLEO_F303RE board
# Support: Serial1 (USART1 on PA10, PA9) and Serial2 (USART2 on PA1, PA0)
Nucleo_64.menu.board_part_num.NUCLEO_F303RE=Nucleo F303RE
Expand Down Expand Up @@ -189,6 +203,20 @@ Disco.build.core=arduino
Disco.build.board=Disco
Disco.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.enable_Serialx}

#DISCO_F100RB board
# Support: Serial1 (USART1 on PA10, PA9) and Serial2 (USART3 on PB11, PB10)
Disco.menu.board_part_num.DISCO_F100RB=STM32F100RB-DISCVL
Disco.menu.board_part_num.DISCO_F100RB.node=DIS_F100RB
Disco.menu.board_part_num.DISCO_F100RB.upload.maximum_size=131071
Disco.menu.board_part_num.DISCO_F100RB.upload.maximum_data_size=8192
Disco.menu.board_part_num.DISCO_F100RB.build.mcu=cortex-m3
Disco.menu.board_part_num.DISCO_F100RB.build.f_cpu=24000000L
Disco.menu.board_part_num.DISCO_F100RB.build.board=DISCO_F100RB
Disco.menu.board_part_num.DISCO_F100RB.build.series=STM32F1xx
Disco.menu.board_part_num.DISCO_F100RB.build.product_line=STM32F100xB
Disco.menu.board_part_num.DISCO_F100RB.build.variant=DISCO_F100RB
Disco.menu.board_part_num.DISCO_F100RB.build.cmsis_lib_gcc=arm_cortexM3l_math

# DISCO_F407VG board
# Support: USB HID
Disco.menu.board_part_num.DISCO_F407VG=STM32F407G-DISC1
Expand Down Expand Up @@ -226,6 +254,79 @@ Disco.menu.upload_method.STLinkMethod=STLink
Disco.menu.upload_method.STLinkMethod.upload.protocol=STLink
Disco.menu.upload_method.STLinkMethod.upload.tool=stlink_upload

################################################################################
# Other boards

Other.name=Other

Other.build.vid=0x0483
Other.build.pid=0x5711
Other.vid.0=0x0483
Other.pid.0=0x5711

Other.build.core=arduino
Other.build.board=Other
Other.build.extra_flags=-D{build.product_line} {build.upload_flags} {build.enable_usb} {build.enable_Serialx}

# BLUEPILL_F103C8 board
# Support: USB HID, Serial2 (USART2 on PA3, PA2) and Serial3 (USART3 on PB11, PB10)
Other.menu.board_part_num.BLUEPILL_F103C8=BluePill F103C8
Other.menu.board_part_num.BLUEPILL_F103C8.node=NODE_F103C8
Other.menu.board_part_num.BLUEPILL_F103C8.upload.maximum_size=65536
Other.menu.board_part_num.BLUEPILL_F103C8.upload.maximum_data_size=20480
Other.menu.board_part_num.BLUEPILL_F103C8.build.mcu=cortex-m3
Other.menu.board_part_num.BLUEPILL_F103C8.build.f_cpu=72000000L
Other.menu.board_part_num.BLUEPILL_F103C8.build.board=BLUEPILL_F103C8
Other.menu.board_part_num.BLUEPILL_F103C8.build.series=STM32F1xx
Other.menu.board_part_num.BLUEPILL_F103C8.build.product_line=STM32F103xB
Other.menu.board_part_num.BLUEPILL_F103C8.build.variant=BLUEPILL_F103C8
Other.menu.board_part_num.BLUEPILL_F103C8.build.cmsis_lib_gcc=arm_cortexM3l_math

# MAPLEMINI_F103CB board
# Support: USB HID, Serial2 (USART2 on PA3, PA2) and Serial3 (USART3 on PB11, PB10)
Other.menu.board_part_num.MAPLEMINI_F103CB=MapleMini F103CB
Other.menu.board_part_num.MAPLEMINI_F103CB.node=NODE_F103CB
Other.menu.board_part_num.MAPLEMINI_F103CB.upload.maximum_size=131072
Other.menu.board_part_num.MAPLEMINI_F103CB.upload.maximum_data_size=20480
Other.menu.board_part_num.MAPLEMINI_F103CB.build.mcu=cortex-m3
Other.menu.board_part_num.MAPLEMINI_F103CB.build.f_cpu=72000000L
Other.menu.board_part_num.MAPLEMINI_F103CB.build.board=MAPLEMINI_F103CB
Other.menu.board_part_num.MAPLEMINI_F103CB.build.series=STM32F1xx
Other.menu.board_part_num.MAPLEMINI_F103CB.build.product_line=STM32F103xB
Other.menu.board_part_num.MAPLEMINI_F103CB.build.variant=MAPLEMINI_F103CB
Other.menu.board_part_num.MAPLEMINI_F103CB.build.cmsis_lib_gcc=arm_cortexM3l_math

Other.menu.upload_method.DFUUploadMethod1=Maple bootloader (original version for Maple boards)
Other.menu.upload_method.DFUUploadMethod1.upload.protocol=maple_dfu
Other.menu.upload_method.DFUUploadMethod1.upload.tool=maple_upload
Other.menu.upload_method.DFUUploadMethod1.build.upload_flags=-DSERIAL_USB -DVECT_TAB_OFFSET=0x5000
Other.menu.upload_method.DFUUploadMethod1.build.ldscript=bootloader_original.ld
Other.menu.upload_method.DFUUploadMethod1.upload.usbID=1EAF:0003
Other.menu.upload_method.DFUUploadMethod1.upload.altID=1

Other.menu.upload_method.DFUUploadMethod=STM32duino bootloader
Other.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu
Other.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload
Other.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DVECT_TAB_OFFSET=0x2000
Other.menu.upload_method.DFUUploadMethod.build.ldscript=bootloader.ld
Other.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003
Other.menu.upload_method.DFUUploadMethod.upload.altID=2

Other.menu.upload_method.STLinkMethod=STLink
Other.menu.upload_method.STLinkMethod.upload.protocol=STLink
Other.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
Other.menu.upload_method.STLinkMethod.build.upload_flags=-DSERIAL_USB

Other.menu.upload_method.serialMethod=Serial
Other.menu.upload_method.serialMethod.upload.protocol=maple_serial
Other.menu.upload_method.serialMethod.upload.tool=serial_upload
Other.menu.upload_method.serialMethod.build.upload_flags=

Other.menu.upload_method.BMPMethod=BMP (Black Magic Probe)
Other.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
Other.menu.upload_method.BMPMethod.upload.tool=bmp_upload
Other.menu.upload_method.BMPMethod.upload.speed=230400
Other.menu.upload_method.BMPMethod.build.upload_flags=

################################################################################
# Serialx activation
Expand Down Expand Up @@ -261,6 +362,14 @@ Disco.menu.Other_serial.enable_Serial1.build.enable_Serialx=-DENABLE_SERIAL1
Disco.menu.Other_serial.enable_Serial2=Serial2 (if available)
Disco.menu.Other_serial.enable_Serial2.build.enable_Serialx=-DENABLE_SERIAL2

Other.menu.Other_serial.enable_Serial=None
Other.menu.Other_serial.enable_SerialAll=All
Other.menu.Other_serial.enable_SerialAll.build.enable_Serialx=-DENABLE_SERIAL2 -DENABLE_SERIAL2
Other.menu.Other_serial.enable_Serial2=Serial2 (if available)
Other.menu.Other_serial.enable_Serial2.build.enable_Serialx=-DENABLE_SERIAL2
Other.menu.Other_serial.enable_Serial3=Serial3 (if available)
Other.menu.Other_serial.enable_Serial3.build.enable_Serialx=-DENABLE_SERIAL3

# USB connectivity
Nucleo_144.menu.USB_interface.enable_USB=None
Nucleo_144.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available)
Expand All @@ -285,3 +394,9 @@ Disco.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available
Disco.menu.USB_interface.enable_HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
Disco.menu.USB_interface.enable_CDC=CDC (if available)
Disco.menu.USB_interface.enable_CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DUSE_USB_FS

Other.menu.USB_interface.enable_USB=None
Other.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available)
Other.menu.USB_interface.enable_HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
Other.menu.USB_interface.enable_CDC=CDC (if available)
Other.menu.USB_interface.enable_CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DUSE_USB_FS
1 change: 1 addition & 0 deletions cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ extern void loop( void ) ;
#include "WMath.h"
#include "HardwareSerial.h"
#include "wiring_pulse.h"
#include "USBSerial.h"
#endif // __cplusplus


Expand Down
212 changes: 212 additions & 0 deletions cores/arduino/USBSerial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
/****************************************************************************
*
* USBSerial core library for Arduino STM32 + HAL + CubeMX (HALMX).
*
* Copyright (c) 2016 by Vassilis Serasidis <[email protected]>
* Home: http://www.serasidis.gr
* email: [email protected]
*
* Arduino_STM32 forum: http://www.stm32duino.com
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all copies.
*
* Some functions follow the sam and samd arduino core libray files.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
*
****************************************************************************/

#include <chip.h>

#if defined(SERIAL_USB) && defined(USBCON)
#include <USBSerial.h>
#include "variant.h"

// Constructors ////////////////////////////////////////////////////////////////
USBSerial::USBSerial(){
// Make sure Rx ring buffer is initialized back to empty.
rx_buffer.iHead = rx_buffer.iTail = 0;
//tx_buffer.iHead = tx_buffer.iTail = 0;
}

void USBSerial::init(void){
/* Re-enumerate the USB */
volatile unsigned int i;

#ifdef USB_DISC_PIN
pinMode(USB_DISC_PIN, OUTPUT);
digitalWrite(USB_DISC_PIN, HIGH);
for(i=0;i<512;i++);
digitalWrite(USB_DISC_PIN, LOW);
#else
#error "USB_DISC_PIN definition missing"
#endif
MX_USB_DEVICE_Init();
}


void USBSerial::begin(uint32_t baud_count){
init();
// suppress "unused parameter" warning
(void)baud_count;
}

void USBSerial::begin(uint32_t baud_count, uint8_t config){
init();
//suppress "unused parameter" warning
(void)baud_count;
(void)config;
}

void USBSerial::end(void){

}


int USBSerial::availableForWrite(void){
//return (CDC_SERIAL_BUFFER_SIZE - available());
//return (uint32_t)(CDC_SERIAL_BUFFER_SIZE + tx_buffer.iHead - tx_buffer.iTail) % CDC_SERIAL_BUFFER_SIZE;
return 0;
}


int USBSerial::available(void){
return (uint32_t)(CDC_SERIAL_BUFFER_SIZE + rx_buffer.iHead - rx_buffer.iTail) % CDC_SERIAL_BUFFER_SIZE;
}

int USBSerial::peek(void)
{
if ( rx_buffer.iHead == rx_buffer.iTail )
return -1;

return rx_buffer.buffer[rx_buffer.iTail];
}

int USBSerial::read(void)
{
// if the head isn't ahead of the tail, we don't have any characters
if ( rx_buffer.iHead == rx_buffer.iTail )
return -1;

uint8_t uc = rx_buffer.buffer[rx_buffer.iTail];
rx_buffer.iTail = (unsigned int)(rx_buffer.iTail + 1) % CDC_SERIAL_BUFFER_SIZE;

return uc;
}

void USBSerial::flush(void){
//It's not implemented yet.
}

size_t USBSerial::write(const uint8_t *buffer, size_t size){
unsigned long timeout=millis()+5;
if(hUsbDeviceFS.dev_state == USBD_STATE_CONFIGURED)
{
while(millis()<timeout)
{
if(CDC_Transmit_FS((uint8_t*)buffer, size) == USBD_OK)
{
return size;
}
}
}

return 0;


/* uint8_t i;

if(hUsbDeviceFS.dev_state == USBD_STATE_CONFIGURED){

//HAL_NVIC_DisableIRQ(USB_LP_CAN1_RX0_IRQn);
for(i=0;i<200;i++)
if(CDC_Transmit_FS((uint8_t*)buffer, size) == USBD_OK){
return size;
//break;
}


//HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
}
return 0; */
}

size_t USBSerial::write(uint8_t c) {
return write(&c, 1);
}

void USBSerial::CDC_RxHandler (uint8_t* Buf, uint16_t Len){

for(uint16_t i=0;i<Len;i++){
if(available() < (CDC_SERIAL_BUFFER_SIZE - 1)){
rx_buffer.buffer[rx_buffer.iHead] = *Buf++;
rx_buffer.iHead = (uint16_t)(rx_buffer.iHead + 1) % CDC_SERIAL_BUFFER_SIZE;
}else
break;
}
}


// This operator is a convenient way for a sketch to check whether the
// port has actually been configured and opened by the host (as opposed
// to just being connected to the host). It can be used, for example, in
// setup() before printing to ensure that an application on the host is
// actually ready to receive and display the data.
// We add a short delay before returning to fix a bug observed by Federico
// where the port is configured (lineState != 0) but not quite opened.
USBSerial::operator bool()
{
// this is here to avoid spurious opening after upload
if (millis() < 500)
return false;

bool result = false;

/* if (_usbLineInfo.lineState > 0)
{
result = true;
}

delay(10); */
return result;
}

uint32_t USBSerial::baud() {
//return _usbLineInfo.dwDTERate;
return 0;
}

uint8_t USBSerial::stopbits() {
//return _usbLineInfo.bCharFormat;
return 0;
}

uint8_t USBSerial::paritytype() {
//return _usbLineInfo.bParityType;
return 0;
}

uint8_t USBSerial::numbits() {
//return _usbLineInfo.bDataBits;
return 0;
}

bool USBSerial::dtr() {
//return _usbLineInfo.lineState & 0x1;
return 0;
}

bool USBSerial::rts() {
//return _usbLineInfo.lineState & 0x2;
return 0;
}

#endif
Loading