2015-02-06 14:35:48 +00:00
|
|
|
/*
|
2017-06-30 08:22:17 +01:00
|
|
|
* This file is part of the MicroPython project, http://micropython.org/
|
2015-02-06 14:35:48 +00:00
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013, 2014 Damien P. George
|
|
|
|
* Copyright (c) 2015 Daniel Campora
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.
This commit ensures that all header files of the MicroPython project (that
were not simply copied from somewhere else) follow the same pattern, that
was already present in the majority of files, especially in the py folder.
The rules are as follows.
Naming convention:
* start with the words MICROPY_INCLUDED
* contain the full path to the file
* replace special characters with _
In addition, there are no empty lines before #ifndef, between #ifndef and
one empty line before #endif. #endif is followed by a comment containing
the name of the guard macro.
py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
2017-06-29 22:14:58 +01:00
|
|
|
#ifndef MICROPY_INCLUDED_CC3200_MODS_PYBPIN_H
|
|
|
|
#define MICROPY_INCLUDED_CC3200_MODS_PYBPIN_H
|
2015-03-28 20:46:48 +00:00
|
|
|
|
2015-05-02 21:57:51 +01:00
|
|
|
enum {
|
2015-09-04 13:36:52 +01:00
|
|
|
PORT_A0 = GPIOA0_BASE,
|
|
|
|
PORT_A1 = GPIOA1_BASE,
|
|
|
|
PORT_A2 = GPIOA2_BASE,
|
|
|
|
PORT_A3 = GPIOA3_BASE,
|
2015-05-02 21:57:51 +01:00
|
|
|
};
|
|
|
|
|
2015-09-04 13:36:52 +01:00
|
|
|
enum {
|
|
|
|
PIN_FN_UART = 0,
|
|
|
|
PIN_FN_SPI,
|
|
|
|
PIN_FN_I2S,
|
|
|
|
PIN_FN_I2C,
|
|
|
|
PIN_FN_TIM,
|
|
|
|
PIN_FN_SD,
|
|
|
|
PIN_FN_ADC,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PIN_TYPE_UART_TX = 0,
|
|
|
|
PIN_TYPE_UART_RX,
|
|
|
|
PIN_TYPE_UART_RTS,
|
|
|
|
PIN_TYPE_UART_CTS,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PIN_TYPE_SPI_CLK = 0,
|
|
|
|
PIN_TYPE_SPI_MOSI,
|
|
|
|
PIN_TYPE_SPI_MISO,
|
|
|
|
PIN_TYPE_SPI_CS0,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PIN_TYPE_I2S_CLK = 0,
|
|
|
|
PIN_TYPE_I2S_FS,
|
|
|
|
PIN_TYPE_I2S_DAT0,
|
|
|
|
PIN_TYPE_I2S_DAT1,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PIN_TYPE_I2C_SDA = 0,
|
|
|
|
PIN_TYPE_I2C_SCL,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2016-02-14 12:46:04 +00:00
|
|
|
PIN_TYPE_TIM_PWM = 0,
|
2015-09-04 13:36:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PIN_TYPE_SD_CLK = 0,
|
|
|
|
PIN_TYPE_SD_CMD,
|
|
|
|
PIN_TYPE_SD_DAT0,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2015-09-14 19:03:32 +01:00
|
|
|
PIN_TYPE_ADC_CH0 = 0,
|
|
|
|
PIN_TYPE_ADC_CH1,
|
|
|
|
PIN_TYPE_ADC_CH2,
|
|
|
|
PIN_TYPE_ADC_CH3,
|
2015-09-04 13:36:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
qstr name;
|
2015-09-14 19:03:32 +01:00
|
|
|
int8_t idx;
|
2015-09-04 13:36:52 +01:00
|
|
|
uint8_t fn;
|
|
|
|
uint8_t unit;
|
|
|
|
uint8_t type;
|
|
|
|
} pin_af_t;
|
|
|
|
|
2015-02-06 14:35:48 +00:00
|
|
|
typedef struct {
|
2015-03-04 12:52:39 +00:00
|
|
|
const mp_obj_base_t base;
|
|
|
|
const qstr name;
|
|
|
|
const uint32_t port;
|
2015-09-04 13:36:52 +01:00
|
|
|
const pin_af_t *af_list;
|
2015-08-18 13:07:19 +01:00
|
|
|
uint16_t pull;
|
2015-03-04 12:52:39 +00:00
|
|
|
const uint8_t bit;
|
|
|
|
const uint8_t pin_num;
|
2015-08-18 13:07:19 +01:00
|
|
|
int8_t af;
|
2015-03-04 12:52:39 +00:00
|
|
|
uint8_t strength;
|
2015-09-04 13:36:52 +01:00
|
|
|
uint8_t mode; // this is now a combination of type and mode
|
2015-09-22 22:20:29 +01:00
|
|
|
const uint8_t num_afs; // 255 AFs
|
|
|
|
uint8_t value;
|
|
|
|
uint8_t used;
|
|
|
|
uint8_t irq_trigger;
|
|
|
|
uint8_t irq_flags;
|
2015-02-09 18:38:02 +00:00
|
|
|
} pin_obj_t;
|
2015-02-06 14:35:48 +00:00
|
|
|
|
2015-02-09 18:38:02 +00:00
|
|
|
extern const mp_obj_type_t pin_type;
|
2015-02-06 14:35:48 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2015-03-04 12:52:39 +00:00
|
|
|
const char *name;
|
|
|
|
const pin_obj_t *pin;
|
2015-02-09 18:38:02 +00:00
|
|
|
} pin_named_pin_t;
|
2015-02-06 14:35:48 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
mp_obj_base_t base;
|
|
|
|
qstr name;
|
2015-02-09 18:38:02 +00:00
|
|
|
const pin_named_pin_t *named_pins;
|
|
|
|
} pin_named_pins_obj_t;
|
2015-02-06 14:35:48 +00:00
|
|
|
|
2015-08-18 13:07:19 +01:00
|
|
|
extern const mp_obj_type_t pin_board_pins_obj_type;
|
|
|
|
extern const mp_obj_dict_t pin_board_pins_locals_dict;
|
2015-02-06 14:35:48 +00:00
|
|
|
|
2015-02-09 18:38:02 +00:00
|
|
|
void pin_init0(void);
|
2015-08-18 13:07:19 +01:00
|
|
|
void pin_config(pin_obj_t *self, int af, uint mode, uint type, int value, uint strength);
|
2015-03-04 12:52:39 +00:00
|
|
|
pin_obj_t *pin_find(mp_obj_t user_obj);
|
2015-09-08 14:07:42 +01:00
|
|
|
void pin_assign_pins_af (mp_obj_t *pins, uint32_t n_pins, uint32_t pull, uint32_t fn, uint32_t unit);
|
2015-09-11 08:33:19 +01:00
|
|
|
uint8_t pin_find_peripheral_unit (const mp_obj_t pin, uint8_t fn, uint8_t type);
|
2015-09-14 19:03:32 +01:00
|
|
|
uint8_t pin_find_peripheral_type (const mp_obj_t pin, uint8_t fn, uint8_t unit);
|
2016-02-14 12:46:04 +00:00
|
|
|
int8_t pin_find_af_index (const pin_obj_t* pin, uint8_t fn, uint8_t unit, uint8_t type);;
|
2015-02-06 14:35:48 +00:00
|
|
|
|
all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.
This commit ensures that all header files of the MicroPython project (that
were not simply copied from somewhere else) follow the same pattern, that
was already present in the majority of files, especially in the py folder.
The rules are as follows.
Naming convention:
* start with the words MICROPY_INCLUDED
* contain the full path to the file
* replace special characters with _
In addition, there are no empty lines before #ifndef, between #ifndef and
one empty line before #endif. #endif is followed by a comment containing
the name of the guard macro.
py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
2017-06-29 22:14:58 +01:00
|
|
|
#endif // MICROPY_INCLUDED_CC3200_MODS_PYBPIN_H
|