Giter VIP home page Giter VIP logo

mi_sisaux2016's Introduction

MI_sisAux2016

Repositório dedicado ao desenvolvimento do Módulo de Interface de Acionamento dos Sistemas Auxiliares de 2016.

mi_sisaux2016's People

Contributors

joaoantoniocardoso avatar

Watchers

James Cloos avatar  avatar Marcio Antonio Augusto avatar Augusto Rodrigues avatar Natan Ogliari avatar

mi_sisaux2016's Issues

software

// coding: utf-8

include <avr/io.h>

include <avr/pgmspace.h>

include "can.h"

include "avr/wdt.h"

define aciBomba1 PD3

define aciBomba2 PD4

define aciMPPT PD5

define aux1 PD6

define aux2 PD7

// -----------------------------------------------------------------------------
/** Set filters and masks.
*

  • The filters are divided in two groups:
    *
  • Group 0: Filter 0 and 1 with corresponding mask 0.
  • Group 1: Filter 2, 3, 4 and 5 with corresponding mask 1.
    *
  • If a group mask is set to 0, the group will receive all messages.
    *
  • If you want to receive ONLY 11 bit identifiers, set your filters
  • and masks as follows:
    *
  • uint8_t can_filter[] PROGMEM = {
  •  // Group 0
    
  •  MCP2515_FILTER(0),              // Filter 0
    
  •  MCP2515_FILTER(0),              // Filter 1
    
  •  // Group 1
    
  •  MCP2515_FILTER(0),              // Filter 2
    
  •  MCP2515_FILTER(0),              // Filter 3
    
  •  MCP2515_FILTER(0),              // Filter 4
    
  •  MCP2515_FILTER(0),              // Filter 5
    
  •  MCP2515_FILTER(0),              // Mask 0 (for group 0)
    
  •  MCP2515_FILTER(0),              // Mask 1 (for group 1)
    
  • };
  • If you want to receive ONLY 29 bit identifiers, set your filters

  • and masks as follows:
    *

  • \code

  • uint8_t can_filter[] PROGMEM = {

  •  // Group 0
    
  •  MCP2515_FILTER_EXTENDED(0),     // Filter 0
    
  •  MCP2515_FILTER_EXTENDED(0),     // Filter 1
    
  •  // Group 1
    
  •  MCP2515_FILTER_EXTENDED(0),     // Filter 2
    
  •  MCP2515_FILTER_EXTENDED(0),     // Filter 3
    
  •  MCP2515_FILTER_EXTENDED(0),     // Filter 4
    
  •  MCP2515_FILTER_EXTENDED(0),     // Filter 5
    
  •  MCP2515_FILTER_EXTENDED(0),     // Mask 0 (for group 0)
    
  •  MCP2515_FILTER_EXTENDED(0),     // Mask 1 (for group 1)
    
  • };

  • \endcode
    *

  • If you want to receive both 11 and 29 bit identifiers, set your filters

  • and masks as follows:
    */
    const uint8_t can_filter[] PROGMEM =
    {
    // Group 0
    MCP2515_FILTER(0), // Filter 0
    MCP2515_FILTER(0), // Filter 1

    // Group 1
    MCP2515_FILTER_EXTENDED(0), // Filter 2
    MCP2515_FILTER_EXTENDED(0), // Filter 3
    MCP2515_FILTER_EXTENDED(0), // Filter 4
    MCP2515_FILTER_EXTENDED(0), // Filter 5

    MCP2515_FILTER(0), // Mask 0 (for group 0)
    MCP2515_FILTER_EXTENDED(0), // Mask 1 (for group 1)
    };
    // You can receive 11 bit identifiers with either group 0 or 1.

// -----------------------------------------------------------------------------
// Main loop for receiving and sending messages.

int main(void)
{

typedef union estados_t{
    struct {
        unsigned char estBomba1 : 1;
        unsigned char estBomba2 : 1;
        unsigned char estMPPT   : 1;
        unsigned char estAux1   : 1;
        unsigned char estAux2   : 1;
    };
    unsigned char todas;
} estados_t;

volatile estados_t estados;

// Initialize MCP2515
can_init(BITRATE_125_KBPS);

// Load filters and masks
can_static_filter(can_filter);




// Create a test messsage
can_t msg;

msg.id = 0x123;
msg.flags.rtr = 0;
msg.flags.extended = 0;

msg.length = 4;
msg.data[0] = 0xde;
msg.data[1] = 0xad;
msg.data[2] = 0xbe;
msg.data[3] = 0xef;

// Send the message
can_send_message(&msg);

while (1)
{
    // Check if a new messag was received
    if (can_check_message())
    {
        can_t msg;

        // Try to read the message
        if (can_get_message(&msg))
        {
            // If we received a message resend it with a different id
            msg.id += 10;

            // Send the new message
            can_send_message(&msg);
        }
    }
}

return 0;

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.