Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 5bb05fa

Browse files
cparatafpistm
authored andcommitted
Add Wire1 and Wire2 instances
Signed-off-by: Carlo.Parata <carlo.parata@st.com>
1 parent d09b8e4 commit 5bb05fa

File tree

5 files changed

+32
-17
lines changed

5 files changed

+32
-17
lines changed

libraries/Wire/Wire.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,4 +376,6 @@ void TwoWire::onRequest( void (*function)(void) )
376376

377377
// Preinstantiate Objects //////////////////////////////////////////////////////
378378

379-
TwoWire Wire = TwoWire(); //D14-D15
379+
TwoWire Wire = TwoWire(SDA, SCL); //D70-D71
380+
TwoWire Wire1 = TwoWire(SDA1, SCL1); //D20-D21
381+
TwoWire Wire2 = TwoWire(SDA2, SCL2); //D79-D80

libraries/Wire/Wire.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,7 @@ class TwoWire : public Stream
9090
};
9191

9292
extern TwoWire Wire;
93+
extern TwoWire Wire1;
94+
extern TwoWire Wire2;
9395

9496
#endif

variants/otto/PeripheralPins.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,24 @@ const PinMap PinMap_DAC[] = {
100100
//*** I2C ***
101101

102102
const PinMap PinMap_I2C_SDA[] = {
103-
// {PB7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // D70 / SDA
104-
// {PB9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // D68 / CANTX
105-
// {PB11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // D19 / RX1
106-
// {PC9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // uSD_D1
107-
// {PF0, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // SDRAM
108-
{PH5, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // D20 / SDA1
109-
// {PH8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // I2C3_SDA
103+
{PB7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF4_I2C1)}, // D70 / SDA
104+
// {PB9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // D68 / CANTX
105+
// {PB11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // D19 / RX1
106+
// {PC9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // uSD_D1
107+
// {PF0, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // SDRAM
108+
{PH5, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF4_I2C2)}, // D20 / SDA1
109+
{PH8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF4_I2C3)}, // I2C3_SDA
110110
{NC, NC, 0}
111111
};
112112

113113
const PinMap PinMap_I2C_SCL[] = {
114114
// {PA8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // D8
115-
// {PB6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // D71 / SCL
115+
{PB6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF4_I2C1)}, // D71 / SCL
116116
// {PB8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // D69 / CANRX
117117
// {PB10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // D18 / TX1
118118
// {PF1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // SDRAM
119-
{PH4, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // D21 / SCL
120-
// {PH7, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // I2C3_SCL
119+
{PH4, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF4_I2C2)}, // D21 / SCL
120+
{PH7, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF4_I2C3)}, // I2C3_SCL
121121
{NC, NC, 0}
122122
};
123123

variants/otto/variant.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ const PinName digital_arduino[] = {
103103
PK4, //D76
104104
PJ3, //D77
105105
PD7, //D78
106+
PH8, //D79
107+
PH7, //D80
106108
};
107109

108110
#ifdef __cplusplus
@@ -225,6 +227,12 @@ void SystemClock_Config(void)
225227

226228
HAL_RCC_EnableCSS();
227229

230+
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
231+
PeriphClkInitStruct.PLLSAI.PLLSAIN = 192;
232+
PeriphClkInitStruct.PLLSAI.PLLSAIR = 7;
233+
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
234+
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
235+
228236
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
229237

230238
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

variants/otto/variant.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ enum {
5555
D40, D41, D42, D43, D44, D45, D46, D47, D48, D49,
5656
D50, D51, D52, D53, D54, D55, D56, D57, D58, D59,
5757
D60, D61, D62, D63, D64, D65, D66, D67, D68, D69,
58-
D70, D71, D72, D73, D74, D75, D76, D77, D78,
58+
D70, D71, D72, D73, D74, D75, D76, D77, D78, D79,
59+
D80,
5960
DEND
6061
};
6162

@@ -74,9 +75,9 @@ enum {
7475
// Convert a digital pin number Dxx to a PinName Pxy
7576
#define digitalToPinName(p) ((p < NUM_DIGITAL_PINS) ? digital_arduino[p] : (STM_VALID_PINNAME(p))? (PinName)p : NC)
7677
// Convert an analog pin number Axx to a PinName Pxy
77-
#define analogToPinName(p) (digitalToPinName(p))
78+
#define analogToPinName(p) ((p < NUM_ANALOG_INPUTS) ? digitalToPinName(p+A0) : digitalToPinName(p))
7879
// Convert an analog pin number to a digital pin number
79-
#define analogToDigital(p) (p)
80+
#define analogToDigital(p) ((p < NUM_ANALOG_INPUTS) ? (p+A0) : p)
8081
// Convert a PinName Pxy to a pin number
8182
uint32_t pinNametoPinNumber(PinName p);
8283

@@ -119,8 +120,8 @@ uint32_t pinNametoPinNumber(PinName p);
119120
#define SS1 D10
120121

121122
// DAC PIN Definition
122-
#define DAC_0 D66
123-
#define DAC_1 D67
123+
#define DAC_0 D66
124+
#define DAC_1 D67
124125

125126
// CAN PIN
126127
#define CANRX D69
@@ -129,8 +130,10 @@ uint32_t pinNametoPinNumber(PinName p);
129130
// I2C PIN
130131
#define SCL D71
131132
#define SDA D70
132-
#define SDA1 D20
133133
#define SCL1 D21
134+
#define SDA1 D20
135+
#define SCL2 D80
136+
#define SDA2 D79
134137

135138
//Timer Definitions
136139
//Do not use timer used by PWM pins when possible. See PinMap_PWM.

0 commit comments

Comments
 (0)