Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

weixiongmei

Member Since 26 Jan 2013
Offline Last Active Feb 19 2016 10:39 PM
-----

#54176 Does any one needs CAN Bus on Netduino?

Posted by weixiongmei on 19 November 2013 - 09:47 PM

 If so,i can port it from my board to Netduino,and here's the sample code how to use the CAN bus in .Net Micro Framework.

 

QQ??20131119165105.jpg

using System;using System.IO;using System.IO.Ports;using System.Text;using System.Threading;using System.Collections;using Microsoft.SPOT;using Microsoft.SPOT.IO;using Microsoft.SPOT.Hardware;using TiroCore.SPOT.Hardware;namespace CAN_Bus{    public class Program    {        public static void Main()        {            //This static function must to be called once before usage            CAN.Initialize();            #region CAN1_Configuration            //Create the configuration for CAN at speed 1 Mbps            CAN.Configuration _CAN_Configuration_CAN1 = new CAN.Configuration()            {                Prescaler = 2,                Mode = CAN.CAN_Mode.Normal,                SJW = CAN.CAN_TimeQuantum.TimeQuantum1,                BS1 = CAN.CAN_TimeQuantum.TimeQuantum8,                BS2 = CAN.CAN_TimeQuantum.TimeQuantum12,                TTCM = false,                ABOM = false,                NART = false,                RFLM = false,                TXFP = false            };            //Create the filter configuration for CAN            CAN.FilterConfiguration _CAN_FilterConfiguration_CAN1 = new CAN.FilterConfiguration()            {                Number = 0,                Mode = CAN.CAN_FilterMode.IdMask,                FIFO = CAN.CAN_FIFO.FIFO0,                Scale = CAN.CAN_FilterScale.FilterScale_32Bit,                IdHeigh = 0x0000,                IdLow = 0x0000,                MaskHeigh = 0x0000,                MaskLow = 0x0000,                Activation = true            };            //Create the reusable transmit message for CAN            CAN.Message _CAN_Message_Transmit_CAN1 = new CAN.Message()            {                StandardId = 0x321,                ExtendedId = 0x01,                RTR = CAN.CAN_RemoteTransmissionRequest.Data,                IDE = CAN.CAN_IdentifierType.Standard,                DLC = 8,                Data = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }            };            //Create the CAN bus            CAN _CAN_CAN1 = new CAN(CAN.CAN_Device.CAN1, _CAN_Configuration_CAN1);            //Binding the receive event to the CAN bus            _CAN_CAN1.OnReceive += CAN_OnReceive;            //Open the CAN bus            _CAN_CAN1.Open();            //Set the filter configuration            _CAN_CAN1.SetFilter(_CAN_FilterConfiguration_CAN1);            //Enable FIFO0 receive interrupt for CAN bus            _CAN_CAN1.SetInterruptState(CAN.CAN_Interrupt.FMP0, true);            #endregion            #region CAN2_Configuration            //Create the configuration for CAN at speed 1 Mbps            CAN.Configuration _CAN_Configuration_CAN2 = new CAN.Configuration()            {                Prescaler = 2,                Mode = CAN.CAN_Mode.Normal,                SJW = CAN.CAN_TimeQuantum.TimeQuantum1,                BS1 = CAN.CAN_TimeQuantum.TimeQuantum8,                BS2 = CAN.CAN_TimeQuantum.TimeQuantum12,                TTCM = false,                ABOM = false,                NART = false,                RFLM = false,                TXFP = false            };            //Create the filter configuration for CAN            CAN.FilterConfiguration _CAN_FilterConfiguration_CAN2 = new CAN.FilterConfiguration()            {                Number = 14,                Mode = CAN.CAN_FilterMode.IdMask,                FIFO = CAN.CAN_FIFO.FIFO0,                Scale = CAN.CAN_FilterScale.FilterScale_32Bit,                IdHeigh = 0x0000,                IdLow = 0x0000,                MaskHeigh = 0x0000,                MaskLow = 0x0000,                Activation = true            };            //Create the reusable transmit message for CAN            CAN.Message _CAN_Message_Transmit_CAN2 = new CAN.Message()            {                StandardId = 0x123,                ExtendedId = 0x01,                RTR = CAN.CAN_RemoteTransmissionRequest.Data,                IDE = CAN.CAN_IdentifierType.Standard,                DLC = 8,                Data = new byte[] { 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 }            };            //Create the CAN bus            CAN _CAN_CAN2 = new CAN(CAN.CAN_Device.CAN2, _CAN_Configuration_CAN2);            //Binding the receive event to the CAN bus            _CAN_CAN2.OnReceive += CAN_OnReceive;            //Open the CAN bus            _CAN_CAN2.Open();            //Set the filter configuration            _CAN_CAN2.SetFilter(_CAN_FilterConfiguration_CAN2);            //Enable FIFO0 receive interrupt for CAN bus            _CAN_CAN2.SetInterruptState(CAN.CAN_Interrupt.FMP0, true);            #endregion            while (true)            {                _CAN_CAN1.Transmit(_CAN_Message_Transmit_CAN1);                _CAN_CAN2.Transmit(_CAN_Message_Transmit_CAN2);                _CAN_Message_Transmit_CAN1.Data[0]++;                _CAN_Message_Transmit_CAN2.Data[7]++;                Thread.Sleep(1000);            }        }        static void CAN_OnReceive(CAN.InterruptEventArgs args, DateTime time)        {            if (args.Message != null)            {                Debug.Print("CAN" + (args.CAN.Device + 1).ToString() + " Data Received:" +                    "{" +                        "0x" + args.Message.Data[0].ToString("X2") + "," +                        "0x" + args.Message.Data[1].ToString("X2") + "," +                        "0x" + args.Message.Data[2].ToString("X2") + "," +                        "0x" + args.Message.Data[3].ToString("X2") + "," +                        "0x" + args.Message.Data[4].ToString("X2") + "," +                        "0x" + args.Message.Data[5].ToString("X2") + "," +                        "0x" + args.Message.Data[6].ToString("X2") + "," +                        "0x" + args.Message.Data[7].ToString("X2") +                    "} Length:" + args.Message.DLC.ToString() + " RAM:" + Debug.GC(false).ToString());            }        }    }}

Attached Files




#53165 .Net Micro framework 4.3 Configurable firmware binary for any STM32F4XX 8.0Mh...

Posted by weixiongmei on 12 October 2013 - 07:12 PM

Instruction please read the readme.txt file in the zip file

 

1.Supports SD1.0/SD2.0 SD/TF cards through SDIO interface

 

2.Supports On Chip RTC

 

3.All pins are configurable through the MFDeploy_WPF.exe without re-compiling the firmware

 

4.Supports debugging ports setting

 

5.Because of test purpose,please contact me ask for the verification key(Serial Key),you have to sent me the the Hardware Serial Number to caculate the Key for you(no cost,it's free).

 

7.Only supports the boards that are using STM32F4XX(1M Flash) and HSE is 8.0Mhz(such as the STM32F407Discovery board)

 

8.To run the MFDeploy_WPF.exe .Net Framework 4.5 is required.

 

9.Reboot and pull high the PA0 for 20s can bring you back to the default debug ports(USB_FS) if you made a fault during setting the debug ports.




#49806 Does any one would like to buy a more powerful STM32F407 MF board?

Posted by weixiongmei on 23 May 2013 - 01:07 AM

Does any one would like to buy a more [color=rgb(255,0,0);]powerful STM32F407(176pins)[/color] .net micro framework development board?

i have designed a development board thats alike to the netduino go,but it has [color=rgb(255,0,0);]more funtions and more performance[/color],such as [color=rgb(255,0,0);]DM9000 ethernet connected to the ETH interface [/color]so the ethernet will be [color=rgb(255,0,0);]much faster than connected to the SPI[/color],and a [color=rgb(255,0,0);]fsmc 3.5 TFT lcd with WPF supported and its much faster than connected to SPI too[/color],[color=rgb(255,0,0);]FSMC 1Gbit on board Nand Flash[/color],[color=rgb(255,0,0);]FSMC 16Mbit on board Nor Flash[/color],[color=rgb(255,0,0);]FSMC 8Mbit of SRAM[/color],and SDIO supported,[color=rgb(255,0,0);]supports up to 32G of sd cards[/color],and [color=rgb(255,0,0);]SDIO faster than the SPI SD[/color]~~~[color=rgb(255,0,0);]it cost about $150-$200[/color],it will [color=rgb(255,0,0);]much cheaper if there are more people going to buy it[/color],and [color=rgb(255,0,0);]all the the hardwares above are inclued in the price[/color],if there are enougth people would like to buy it,then i will go to production,other wise i will just use it by my selft,because im a student,i dont have too much money to waste~~[color=rgb(255,0,0);]thanks for reading[/color]




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.