<commit_before>/**
@file hardware_init.h
@brief Macros to init hardware
@author <NAME>
*/
#ifndef HARDWARE_INIT_H
#define HARDWARE_INIT_H

// The macros below are an obvious abuse of the preprocessor. That said, when
// expanded they are just as efficient as writing a single-line C statement.
// Example:
// LED_PORT 1
// LED_PIN  5
// IO_DIRECTION(LED,GPIO_OUTPUT); expands to P1DIR |= 1;
// IO_DIRECTION(LED,GPIO_INPUT); expands to P1DIR &=~1;

#define _PORT(n)     n##_PORT
#define _PIN(n)      n##_PIN
#Define _REG(n,type) P##n##type

#define CLEAR_OP    &=~
#define SET_OP      |=
#define TOGGLE_OP   ^=

#define GPIO_INPUT  CLEAR_OP
#define GPIO_OUTPUT SET_OP
/**@brief Set the direction of an IO pin as INPUT or OUTPUT */
#define IO_DIRECTION(name,fun)          _IO_DIRECTION(_PORT(name),_PIN(name),fun)
/** @cond IGNORE_DOC */
#define _IO_DIRECTION(port,pin,fun)     _REG(port,DIR) fun _BV(pin)
/** @endcond */

#define GPIO_FUN_IO      CLEAR_OP
#define GPIO_FUN_SPECIAL SET_OP
/**@brief Set function of IO pin */
#define IO_FUNCTION(name,fun)           _IO_FUNCTION(_PORT(name),_PIN(name),fun)
/** @cond IGNORE_DOC */
#ifdef __MSP430G2553__
#define _IO_FUNCTION(port, pin,fun)     _REG(port,SEL) fun _BV(pin)
#elif __MSP430FR5739__
#define _IO_FUNCTION(port, pin,fun)     _REG(port,SEL0) fun _BV(pin)
#endif
/** @endcond */


/**@brief Set auxilary function of IO pin */
#define IO_AUX_FUNCTION(name,fun)       _IO_AUX_FUNCTION(_PORT(name),_PIN(name),fun)
/** @cond IGNORE_DOC */
#ifdef __MSP430G2553__<commit_msg>Fix case in #define<commit_after>/**
@file hardware_init.h
@brief Macros to init hardware
@author <NAME>
*/
#ifndef HARDWARE_INIT_H
#define HARDWARE_INIT_H

// The macros below are an obvious abuse of the preprocessor. That said, when
// expanded they are just as efficient as writing a single-line C statement.
// Example:
// LED_PORT 1
// LED_PIN  5
// IO_DIRECTION(LED,GPIO_OUTPUT); expands to P1DIR |= 1;
// IO_DIRECTION(LED,GPIO_INPUT); expands to P1DIR &=~1;

#define _PORT(n)     n##_PORT
#define _PIN(n)      n##_PIN
#define _REG(n,type) P##n##type

#define CLEAR_OP    &=~
#define SET_OP      |=
#define TOGGLE_OP   ^=

#define GPIO_INPUT  CLEAR_OP
#define GPIO_OUTPUT SET_OP
/**@brief Set the direction of an IO pin as INPUT or OUTPUT */
#define IO_DIRECTION(name,fun)          _IO_DIRECTION(_PORT(name),_PIN(name),fun)
/** @cond IGNORE_DOC */
#define _IO_DIRECTION(port,pin,fun)     _REG(port,DIR) fun _BV(pin)
/** @endcond */

#define GPIO_FUN_IO      CLEAR_OP
#define GPIO_FUN_SPECIAL SET_OP
/**@brief Set function of IO pin */
#define IO_FUNCTION(name,fun)           _IO_FUNCTION(_PORT(name),_PIN(name),fun)
/** @cond IGNORE_DOC */
#ifdef __MSP430G2553__
#define _IO_FUNCTION(port, pin,fun)     _REG(port,SEL) fun _BV(pin)
#elif __MSP430FR5739__
#define _IO_FUNCTION(port, pin,fun)     _REG(port,SEL0) fun _BV(pin)
#endif
/** @endcond */


/**@brief Set auxilary function of IO pin */
#define IO_AUX_FUNCTION(name,fun)       _IO_AUX_FUNCTION(_PORT(name),_PIN(name),fun)
/** @cond IGNORE_DOC */
#ifdef __MSP430G2553__
{'fraction_non_alphanumeric': 0.13130320890635233, 'fraction_numerical': 0.0183366077275704, 'mean_word_length': 4.474910394265233, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3796165', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1142, 'n_words': 296}