<commit_before>//
//  bxCan.hpp
//  Bedrock
//
//  Created by <NAME> on 2016-01-04.
//  Copyright © 2016 EricYanush. All rights reserved.
//

#ifndef bxCan_h
#define bxCan_h

#include <stdint.h>
#include "types.hpp"
#include "CANMessage.hpp"
#include "RCC.hpp"
#include "Delay.hpp"

namespace Bedrock {
    namespace bxCAN {
        
        class TxMailbox {
        public:
            dev_reg32_t TIR;
            dev_reg32_t TDTR;
            dev_reg32_t TDLR;
            dev_reg32_t TDHR;
        };
        
        class RxFIFO {
        public:
            dev_reg32_t RIR;
            dev_reg32_t RDTR;
            dev_reg32_t RDLR;
            dev_reg32_t RDHR;
        };
        
        class Filters {
        public:
            
            /**
             Note: These filter type structs assume little-endian hardware
             which both armv7(e)-m and x86(-64) are.
             */
            struct SingleIDFilter_t {
                uint32_t     : 1,
                rtr : 1,
                ide : 1,
                id  : 29;
                
                SingleIDFilter_t() :
                                 rtr(0), ide(0), id(0) { }
                
                SingleIDFilter_t(uint32_t id, bool ide, bool rtr) :
                                 rtr(rtr), ide(ide), id(id)  {   }
            };
            
            struct SingleMaskFilter_t {
                uint32_t          : 1,
                rtr_mask : 1,
                ide_mask : 1,
                id_mask  : 29;
                
                SingleMaskFilter_t() :
                                   rtr_mask(0), ide_mask(0), id_mask(0) {  }
                
                SingleMaskFilter_t(uint32_t id_mask, bool ide_mask, bool rtr_mask) :
                                   rtr_mask(rtr_mask), ide_mask(ide_mask), id_mask(id_mask) {  }
            };
            
            struct DualIDFilter_t {
                uint16_t extID : 3,
                ide   : 1,
                rtr   : 1,
                id    : 11;
                
                DualIDFilter_t() :
                               ide(0), rtr(0), id(0) {   }
                
                DualIDFilter_t(uint16_t id, bool ide, bool rtr) :
                               ide(ide), rtr(rtr), id(id) {  }
            };
            
            struct DualMaskFilter_t {
                uint16_t extID_mask : 3,
                ide_mask   : 1,
                rtr_mask   : 1,
                id_mask    : 11;
                
                DualMaskFilter_t() :
                                 ide_mask(0), rtr_mask(0), id_mask(0) {  }
                
                DualMaskFilter_t(uint16_t id_mask, bool ide_mask, bool rtr_mask) :
                                 ide_mask(ide_mask), rtr_mask(rtr_mask), id_mask(id_mask) {   }
            };
            
            /**
             Enable a filter bank
             <commit_msg>Ensure single bit padding in single width CAN filter structs are handled correctly.<commit_after>//
//  bxCan.hpp
//  Bedrock
//
//  Created by <NAME> on 2016-01-04.
//  Copyright © 2016 EricYanush. All rights reserved.
//

#ifndef bxCan_h
#define bxCan_h

#include <stdint.h>
#include "types.hpp"
#include "CANMessage.hpp"
#include "RCC.hpp"
#include "Delay.hpp"

namespace Bedrock {
    namespace bxCAN {
        
        class TxMailbox {
        public:
            dev_reg32_t TIR;
            dev_reg32_t TDTR;
            dev_reg32_t TDLR;
            dev_reg32_t TDHR;
        };
        
        class RxFIFO {
        public:
            dev_reg32_t RIR;
            dev_reg32_t RDTR;
            dev_reg32_t RDLR;
            dev_reg32_t RDHR;
        };
        
        class Filters {
        public:
            
            /**
             Note: These filter type structs assume little-endian hardware
             which both armv7(e)-m and x86(-64) are.
             */
            struct SingleIDFilter_t {
                uint32_t __a : 1, //padding
                rtr : 1,
                ide : 1,
                id  : 29;
                
                SingleIDFilter_t() :
                                 __a(0), rtr(0), ide(0), id(0) { }
                
                SingleIDFilter_t(uint32_t id, bool ide, bool rtr) :
                                 __a(0), rtr(rtr), ide(ide), id(id)  {   }
            };
            
            struct SingleMaskFilter_t {
                uint32_t   __a : 1, //padding
                rtr_mask : 1,
                ide_mask : 1,
                id_mask  : 29;
                
                SingleMaskFilter_t() :
                                   __a(0), rtr_mask(0), ide_mask(0), id_mask(0) {  }
                
                SingleMaskFilter_t(uint32_t id_mask, bool ide_mask, bool rtr_mask) :
                                   __a(0), rtr_mask(rtr_mask), ide_mask(ide_mask), id_mask(id_mask) {  }
            };
            
            struct DualIDFilter_t {
                uint16_t extID : 3,
                ide   : 1,
                rtr   : 1,
                id    : 11;
                
                DualIDFilter_t() :
                               ide(0), rtr(0), id(0) {   }
                
                DualIDFilter_t(uint16_t id, bool ide, bool rtr) :
                               ide(ide), rtr(rtr), id(id) {  }
            };
            
            struct DualMaskFilter_t {
                uint16_t extID_mask : 3,
                ide_mask   : 1,
                rtr_mask   : 1,
                id_mask    : 11;
                
                DualMaskFilter_t() :
                                 ide_mask(0), rtr_mask(0), id_mask(0) {  }
                
                DualMaskFilter_t(uint16_t id_mask, bool ide_mask, bool rtr_mask) :
                                 ide_mask(ide_mask), rtr_mask(rtr_mask), id_mask(id_mask) {   }
            };
            
            /**
             Enable a filter bank
             
{'fraction_non_alphanumeric': 0.08373888236281256, 'fraction_numerical': 0.027857022990434636, 'mean_word_length': 0.9281785829828535, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6092907', 'n_tokens_mistral': 1924, 'n_tokens_neox': 1764, 'n_words': 360}