Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- hakusan270
- Date:
- 2020-11-13
- Revision:
- 0:e078ecb37ad7
File content as of revision 0:e078ecb37ad7:
#include "mbed.h"
//勉強会
//STM32 L0 GPIO定義 address 0x5000 0000
// __IO は volatile
// uint32_t は unsigned long
struct GPIO_
{
__IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */
__IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */
__IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */
__IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */
__IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */
__IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */
__IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */
__IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */
__IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */
__IO uint32_t BRR; /*!< GPIO Bit Reset register, Address offset: 0x28 */
};
typedef struct GPIO_ GPIO_T;
DigitalOut myled(LED1);
int main() {
int i=0;
GPIO_T *pGPIO = (GPIO_T *)0x50000000; //GPIO A base address
printf("\r\nGPIO Struct TEST\r\n");
while(1) {
wait(1);
/// myled = !myled;
#if 0
//LED port is GPIO_A bit 5
if (i&1)
//pGPIO->ODR??;
else
//pGPIO->ODR??;
#else
if (i&1)
pGPIO->BSRR = 0x20; //GPIO A BIT5 reset
else
pGPIO->BRR = 0x20 ; ////GPIO A BIT5 set
#endif
i++;
}
}