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.

rcomeau's Content

There have been 3 items by rcomeau (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#30981 Netduinoplus SD card

Posted by rcomeau on 21 June 2012 - 12:35 AM in Beta Firmware and Drivers

will the 4.2 rc5 recognize SD cards larger than 2GB?



#29832 SPI interface with RTC DS3234

Posted by rcomeau on 27 May 2012 - 04:13 PM in Netduino Plus 2 (and Netduino Plus 1)

This is a rewrite and expansion of Rusto's class

//This is rewrite and expansion of the class from netduino forum by Rusko
//needs cleaned up a little but seems to fuction correctly
using System;
using System.Text;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;



namespace RTC_DS3234
{
    class DS3234
    {
        private SPI.Configuration Cfg;
        private SPI ds3234;

        public DS3234(Cpu.Pin SSPin)
        {
            Cfg = new SPI.Configuration(
                SSPin,
                false,
                0,
                0,
                false,
                false,
                2000,
                SPI_Devices.SPI1);

            ds3234 = new SPI(Cfg);
            write(0x8E, 0x60);
        }

        public void Set(DateTime date)
        {
			byte[] buf = {  toBCD(date.Second),
							toBCD(date.Minute),
							toBCD(date.Hour),
							toBCD((int)date.DayOfWeek),
							toBCD(date.Day),
							toBCD(date.Month),
							toBCD(date.Year-2000) };
			write(0x80, buf);
            return;
        }

		private int toHex(byte bcd)
		{
			return (int)(((bcd >> 4) & 0x0f) * 10 + (bcd & 0x0f));
		}

        public DateTime Get()
        {
			byte[] rbuf = read(0x00, 7);
			int year = 2000 + toHex(rbuf[6]),
				month = toHex(rbuf[5]),
				day = toHex(rbuf[4]),
				hour = toHex(rbuf[2]),
				minute = toHex(rbuf[1]),
				second = toHex(rbuf[0]);
            return new DateTime(year, month, day, hour, minute, second);
        }

        public byte ReadSRAM(byte Address)
        {
			byte[] cmdbuf = { 0x98, Address };
			byte[] rbuf = new byte[1];

            ds3234.Write(cmdbuf);
            cmdbuf[0] = 0x19;
            ds3234.WriteRead(cmdbuf, 0, 1, rbuf, 0, 1, 1);
            return rbuf[0];
        }

		public byte[] ReadSRAM(byte Address, int count)
		{
			byte[] cmdbuf = { 0x98, Address };
			byte[] rbuf = new byte[count];

			ds3234.Write(cmdbuf);
			cmdbuf[0] = 0x19;
			ds3234.WriteRead(cmdbuf, 0, 1, rbuf, 0, count, 1);
			return rbuf;
		}

		public void WriteSRAM(byte Address, byte Value)
        {
            byte[] wbuf = { 0x98, Address, Value };
			ds3234.Write(wbuf);
			return;
        }

		public void WriteSRAM(byte Address, byte[] values)
		{
			byte[] wbuf = new byte[values.Length + 2];
			wbuf[0] = 0x98;
			wbuf[1] = Address;
			values.CopyTo(wbuf,2);
			ds3234.Write(wbuf);
			return;
		}

		public float readTemp()
        {
			byte[] rbuf = new byte[2];
			byte[] wbuf = { 0x11 };

            ds3234.WriteRead(wbuf, 0, 1, rbuf, 0, 2, 1);
            int rc = (int)(rbuf[0] << 2) + (rbuf[1] >> 6);
			return rc / 4.0F;
        }

        // Private methods

        private byte toBCD(int val)
        {
            byte a = (byte)(val / 10);
            byte b = (byte)(val % 10);
            return (byte)((a << 4) | B);
        }

		private void write(byte address, byte value)
		{
			byte[] buffer = { address, value };
			ds3234.Write(buffer);
		}

		private void write(byte address, byte[] values)
		{
			byte[] buffer = new byte[values.Length + 1];
			values.CopyTo(buffer, 1);
			buffer[0] = address;
			ds3234.Write(buffer);
		}

		private byte read(byte address){
			byte[] rbuf = new byte[1];
			byte[] wbuf = { address };
			ds3234.WriteRead(wbuf, 0, 1, rbuf, 0, 1, 1);
			return rbuf[0];
		}

		private byte[] read(byte address, int count)
		{
			byte[] rbuf = new byte[count];
			byte[] wbuf = { address };
			ds3234.WriteRead(wbuf, 0, 1, rbuf, 0, count, 1);
			return rbuf;
		}

    }
}




#29593 Netduino Firmware v4.2.0 RC5 (Netduino + Netduino Plus)

Posted by rcomeau on 23 May 2012 - 04:23 PM in Beta Firmware and Drivers

Ok as one new to the netduino plus, where do I find EXACT instructions on how to use SAM-BA to install the 4.2 bootloader? Then what files have to be MFDeployed?




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.