Skip to content

K64F: Fix pin names and migrate to Arduino Uno form factor #14837

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

Merged
merged 2 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions hal/tests/pinvalidate/pinvalidate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python

"""
Copyright (c) 2020 ARM Limited

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
* Copyright (c) 2006-2021 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -198,63 +198,37 @@ typedef enum {
PTE30 = (4 << GPIO_PORT_SHIFT | 30),
PTE31 = (4 << GPIO_PORT_SHIFT | 31),

LED_RED = PTB22,
LED_GREEN = PTE26,
LED_BLUE = PTB21,

// mbed original LED naming
LED1 = LED_RED,
LED2 = LED_GREEN,
LED3 = LED_BLUE,
LED4 = LED_RED,

//Push buttons
SW2 = PTC6,
SW3 = PTA4,
// Standardized button names
BUTTON1 = SW2,
BUTTON2 = SW3,

// USB Pins
CONSOLE_TX = PTB17,
CONSOLE_RX = PTB16,

// Arduino Headers
D0 = PTC16,
D1 = PTC17,
D2 = PTB9,
D3 = PTA1,
D4 = PTB23,
D5 = PTA2,
D6 = PTC2,
D7 = PTC3,
D8 = PTC12,
D9 = PTC4,
D10 = PTD0,
D11 = PTD2,
D12 = PTD3,
D13 = PTD1,
D14 = PTE25,
D15 = PTE24,

I2C_SCL = D15,
I2C_SDA = D14,
ARDUINO_UNO_D0 = PTC16,
ARDUINO_UNO_D1 = PTC17,
ARDUINO_UNO_D2 = PTB9,
ARDUINO_UNO_D3 = PTA1,
ARDUINO_UNO_D4 = PTB23,
ARDUINO_UNO_D5 = PTA2,
ARDUINO_UNO_D6 = PTC2,
ARDUINO_UNO_D7 = PTC3,
ARDUINO_UNO_D8 = PTC12,
ARDUINO_UNO_D9 = PTC4,
ARDUINO_UNO_D10 = PTD0,
ARDUINO_UNO_D11 = PTD2,
ARDUINO_UNO_D12 = PTD3,
ARDUINO_UNO_D13 = PTD1,
ARDUINO_UNO_D14 = PTE25,
ARDUINO_UNO_D15 = PTE24,

A0 = PTB2,
A1 = PTB3,
A2 = PTB10,
A3 = PTB11,
A4 = PTC11,
A5 = PTC10,
ARDUINO_UNO_A0 = PTB2,
ARDUINO_UNO_A1 = PTB3,
ARDUINO_UNO_A2 = PTB10,
ARDUINO_UNO_A3 = PTB11,
ARDUINO_UNO_A4 = PTC11,
ARDUINO_UNO_A5 = PTC10,

DAC0_OUT = 0xFEFE, /* DAC does not have Pin Name in RM */

//SPI Pins configuration
SPI_MOSI = PTE3,
SPI_MISO = PTE1,
SPI_SCK = PTE2,
SPI_CS = PTE4,

// Not connected
NC = (int)0xFFFFFFFF
} PinName;
Expand All @@ -267,6 +241,38 @@ typedef enum {
PullDefault = PullUp
} PinMode;


// LEDs
#define LED_RED PTB22
#define LED_GREEN PTE26
#define LED_BLUE PTB21

// Standardized LED names
#define LED1 LED_RED
#define LED2 LED_GREEN
#define LED3 LED_BLUE


//Push buttons
#define SW2 PTC6
#define SW3 PTA4

// Standardized button names
#define BUTTON1 SW2
#define BUTTON2 SW3


// SPI Pins for SD card.
// Note: They are different from the Arduino Uno SPI pins
// (ARDUINO_UNO_SPI_xxx) for general purpose uses.
// By default, Mbed OS maps those alias to Arduino Uno pins, but
// for backward compatibility we map them to the SD card SPI.
#define SPI_MOSI PTE3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also part of the migration, couldn't it stay in PinName enum and just add a comment or?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SPI pins need to be #defined:

// Legacy SPI aliases
#ifndef SPI_CS
#define SPI_CS ARDUINO_UNO_SPI_CS
#endif

If they were enums, the macro checks would not work.

#define SPI_MISO PTE1
#define SPI_SCK PTE2
#define SPI_CS PTE4


#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion targets/targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@
},
"K64F": {
"supported_form_factors": [
"ARDUINO"
"ARDUINO_UNO"
],
"components_add": [
"SD",
Expand Down