Commit c139abb5 authored by Jake Read's avatar Jake Read

begin embedded

parent 6f556e8a
......@@ -25,7 +25,7 @@ Loc="0 0 1919 1016"
State=1
Number=1
File="mkrouter.sch"
View="-53.2482 15.4592 330.185 261.952"
View="-37.3431 65.3764 184.551 208.023"
WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.2032 0.254 0.3048 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.1524"
PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
PadDrills=" 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6"
......@@ -64,7 +64,7 @@ ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=91
Views=" 1: -53.2482 15.4592 330.185 261.952"
Views=" 1: -37.3431 65.3764 184.551 208.023"
Sheet="1"
[Win_2]
......@@ -73,7 +73,7 @@ Loc="0 0 1919 1016"
State=1
Number=2
File="mkrouter.brd"
View="-3.72245 -3.16486 120.852 66.3506"
View="-17.6895 10.0557 68.8204 58.3304"
WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.254 0.3048 0.2032 0.1524"
PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
PadDrills=" 0.2 0.25 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6 0.3"
......
......@@ -20,7 +20,7 @@
<layer number="24" name="bOrigins" color="15" fill="1" visible="yes" active="yes"/>
<layer number="25" name="tNames" color="7" fill="1" visible="no" active="yes"/>
<layer number="26" name="bNames" color="7" fill="1" visible="no" active="yes"/>
<layer number="27" name="tValues" color="7" fill="1" visible="no" active="yes"/>
<layer number="27" name="tValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="28" name="bValues" color="7" fill="1" visible="no" active="yes"/>
<layer number="29" name="tStop" color="7" fill="3" visible="no" active="yes"/>
<layer number="30" name="bStop" color="7" fill="6" visible="no" active="yes"/>
......@@ -44,7 +44,7 @@
<layer number="48" name="Document" color="7" fill="1" visible="yes" active="yes"/>
<layer number="49" name="Reference" color="7" fill="1" visible="no" active="yes"/>
<layer number="50" name="dxf" color="7" fill="1" visible="no" active="no"/>
<layer number="51" name="tDocu" color="7" fill="1" visible="no" active="yes"/>
<layer number="51" name="tDocu" color="7" fill="1" visible="yes" active="yes"/>
<layer number="52" name="bDocu" color="7" fill="1" visible="no" active="yes"/>
<layer number="53" name="tGND_GNDA" color="7" fill="9" visible="no" active="no"/>
<layer number="54" name="bGND_GNDA" color="1" fill="9" visible="no" active="no"/>
......@@ -951,7 +951,7 @@ design rules under a new name.</description>
</element>
<element name="S2" library="fab" package="6MM_SWITCH" value="" x="25.654" y="44.958" rot="R90"/>
<element name="U1" library="atsam" package="TQFP100-14X14" value="ATSAMS70N-TQFP100" x="18.034" y="30.48"/>
<element name="C1" library="borkedlabs-passives" package="1206" value="4.7uF" x="16.256" y="19.18" rot="R270">
<element name="C1" library="borkedlabs-passives" package="1206" value="10uF" x="16.256" y="19.18" rot="R270">
<attribute name="PACKAGE" value="1206" x="16.256" y="19.18" size="1.778" layer="27" rot="R270" display="off"/>
<attribute name="TYPE" value="" x="16.256" y="19.18" size="1.778" layer="27" rot="R270" display="off"/>
<attribute name="VOLTAGE" value="" x="16.256" y="19.18" size="1.778" layer="27" rot="R270" display="off"/>
......@@ -976,7 +976,7 @@ design rules under a new name.</description>
<attribute name="TYPE" value="" x="14.478" y="40.132" size="1.778" layer="27" rot="R180" display="off"/>
<attribute name="VOLTAGE" value="" x="14.478" y="40.132" size="1.778" layer="27" rot="R180" display="off"/>
</element>
<element name="C6" library="borkedlabs-passives" package="1206" value="1uF" x="11.176" y="19.18" rot="R270">
<element name="C6" library="borkedlabs-passives" package="1206" value="4.7uF" x="11.176" y="19.18" rot="R270">
<attribute name="PACKAGE" value="1206" x="11.176" y="19.18" size="1.778" layer="27" rot="R270" display="off"/>
<attribute name="TYPE" value="" x="11.176" y="19.18" size="1.778" layer="27" rot="R270" display="off"/>
<attribute name="VOLTAGE" value="" x="11.176" y="19.18" size="1.778" layer="27" rot="R270" display="off"/>
......
......@@ -2996,12 +2996,12 @@ Basic schematic elements and footprints for 0603, 1206, and PTH resistors.</desc
<part name="P+1" library="supply1" library_urn="urn:adsk.eagle:library:371" deviceset="+5V" device=""/>
<part name="GND1" library="supply1" library_urn="urn:adsk.eagle:library:371" deviceset="GND" device=""/>
<part name="J2" library="SparkFun-Connectors" deviceset="JST_6_PIN_HORIZONTAL" device="" value="BM06B-SRSS-TB"/>
<part name="C1" library="borkedlabs-passives" deviceset="CAP" device="1206" value="4.7uF"/>
<part name="C1" library="borkedlabs-passives" deviceset="CAP" device="1206" value="10uF"/>
<part name="C2" library="borkedlabs-passives" deviceset="CAP" device="0603-CAP" value="0.1uF"/>
<part name="C3" library="borkedlabs-passives" deviceset="CAP" device="0603-CAP" value="0.1uF"/>
<part name="C4" library="borkedlabs-passives" deviceset="CAP" device="0603-CAP" value="0.1uF"/>
<part name="C5" library="borkedlabs-passives" deviceset="CAP" device="0603-CAP" value="0.1uF"/>
<part name="C6" library="borkedlabs-passives" deviceset="CAP" device="1206" value="1uF"/>
<part name="C6" library="borkedlabs-passives" deviceset="CAP" device="1206" value="4.7uF"/>
<part name="C7" library="borkedlabs-passives" deviceset="CAP" device="0603-CAP" value="0.1uF"/>
<part name="C8" library="borkedlabs-passives" deviceset="CAP" device="0603-CAP" value="0.1uF"/>
<part name="C9" library="borkedlabs-passives" deviceset="CAP" device="0603-CAP" value="0.1uF"/>
......
# Programming the Router
running on code from tinynet...
finding lock bit issue?
setting that does nothing
so, likely that clock is configured incorrectly - will try using erase jumper
changing config from pllack to 8m_rc might have fixed this
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Atmel Studio Solution File, Format Version 11.00
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "mkrouter-v04", "mkrouter-v04\mkrouter-v04.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Release|ARM = Release|ARM
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|ARM.ActiveCfg = Debug|ARM
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|ARM.Build.0 = Debug|ARM
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|ARM.ActiveCfg = Release|ARM
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|ARM.Build.0 = Release|ARM
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
This diff is collapsed.
################################################################################
# Automatically-generated file. Do not edit or delete the file
################################################################################
src\pin.c
src\ASF\common\services\delay\sam\cycle_counter.c
src\ASF\common\services\clock\sams70\sysclk.c
src\ASF\sam\drivers\pmc\pmc.c
src\ASF\sam\drivers\pmc\sleep.c
src\ASF\common\boards\user_board\init.c
src\ASF\common\utils\interrupt\interrupt_sam_nvic.c
src\ASF\sam\utils\cmsis\sams70\source\templates\gcc\startup_sams70.c
src\ASF\sam\utils\cmsis\sams70\source\templates\system_sams70.c
src\ASF\sam\utils\syscalls\gcc\syscalls.c
src\main.c
<?xml version="1.0" encoding="utf-8"?>
<Store xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="AtmelPackComponentManagement">
<ProjectComponents />
</Store>
\ No newline at end of file
This diff is collapsed.
/**
* \file
*
* \brief Autogenerated API include file for the Atmel Software Framework (ASF)
*
* Copyright (c) 2012 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \asf_license_stop
*
*/
#ifndef ASF_H
#define ASF_H
/*
* This file includes all API header files for the selected drivers from ASF.
* Note: There might be duplicate includes required by more than one driver.
*
* The file is automatically generated and will be re-written when
* running the ASF driver selector tool. Any changes will be discarded.
*/
// From module: Common SAM compiler driver
#include <compiler.h>
#include <status_codes.h>
// From module: Common build items for user board support templates
#include <user_board.h>
// From module: Delay routines
#include <delay.h>
// From module: Generic board support
#include <board.h>
// From module: Interrupt management - SAM implementation
#include <interrupt.h>
// From module: PMC - Power Management Controller
#include <pmc.h>
#include <sleep.h>
// From module: Part identification macros
#include <parts.h>
// From module: SAM FPU driver
#include <fpu.h>
// From module: System Clock Control - SAMS70 implementation
#include <sysclk.h>
#endif // ASF_H
/**
* \file
*
* \brief User board configuration template
*
*/
/*
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#ifndef CONF_BOARD_H
#define CONF_BOARD_H
// a bunch of BS bc we don't have any xtals
#define BOARD_FREQ_SLCK_XTAL (32768UL)
#define BOARD_FREQ_SLCK_BYPASS (32768UL)
#define BOARD_FREQ_MAINCK_XTAL (12000000UL)
#define BOARD_FREQ_MAINCK_BYPASS (12000000UL)
#define BOARD_OSC_STARTUP_US (12625UL)
#endif // CONF_BOARD_H
/**
* \file
*
* \brief SAMS70 clock configuration.
*
* Copyright (c) 2015 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \asf_license_stop
*
*/
/*
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#ifndef CONF_CLOCK_H_INCLUDED
#define CONF_CLOCK_H_INCLUDED
// ===== System Clock (MCK) Source Options
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_SLCK_RC
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_SLCK_XTAL
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_SLCK_BYPASS
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_4M_RC
#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_8M_RC
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_12M_RC
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_XTAL
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_BYPASS
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLLACK
//#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_UPLLCK
// ===== Processor Clock (HCLK) Prescaler Options (Fhclk = Fsys / (SYSCLK_PRES))
#define CONFIG_SYSCLK_PRES SYSCLK_PRES_1
//#define CONFIG_SYSCLK_PRES SYSCLK_PRES_2
//#define CONFIG_SYSCLK_PRES SYSCLK_PRES_4
//#define CONFIG_SYSCLK_PRES SYSCLK_PRES_8
//#define CONFIG_SYSCLK_PRES SYSCLK_PRES_16
//#define CONFIG_SYSCLK_PRES SYSCLK_PRES_32
//#define CONFIG_SYSCLK_PRES SYSCLK_PRES_64
//#define CONFIG_SYSCLK_PRES SYSCLK_PRES_3
// ===== System Clock (MCK) Division Options (Fmck = Fhclk / (SYSCLK_DIV))
#define CONFIG_SYSCLK_DIV 1
// ===== PLL0 (A) Options (Fpll = (Fclk * PLL_mul) / PLL_div)
// Use mul and div effective values here.
#define CONFIG_PLL0_SOURCE PLL_SRC_MAINCK_XTAL
#define CONFIG_PLL0_MUL 25
#define CONFIG_PLL0_DIV 1
// ===== UPLL (UTMI) Hardware fixed at 480 MHz.
// ===== USB Clock Source Options (Fusb = FpllX / USB_div)
// Use div effective value here.
//#define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL0
#define CONFIG_USBCLK_SOURCE USBCLK_SRC_UPLL
#define CONFIG_USBCLK_DIV 1
// ===== Target frequency (Processor clock)
// - XTAL frequency: 12MHz
// - System clock source: PLLA
// - System clock prescaler: 1 (divided by 1)
// - System clock divider: 2 (divided by 2)
// - PLLA source: XTAL
// - PLLA output: XTAL * 25 / 1
// - Processor clock: 12 * 25 / 1 / 1 = 300MHz
// - System clock: 300 / 2 = 150MHz
// ===== Target frequency (USB Clock)
// - USB clock source: UPLL
// - USB clock divider: 1 (not divided)
// - UPLL frequency: 480MHz
// - USB clock: 480 / 1 = 480MHz
#endif /* CONF_CLOCK_H_INCLUDED */
/*
* hardware.h
*
* Created: 2/21/2018 6:28:28 PM
* Author: Jake
*/
#ifndef HARDWARE_H_
#define HARDWARE_H_
#include "pin.h"
pin_t np1stlr;
pin_t np1stlg;
pin_t np1stlb;
#endif /* HARDWARE_H_ */
\ No newline at end of file
/**
* \file
*
* \brief Empty user application template
*
*/
/**
* \mainpage User Application template doxygen documentation
*
* \par Empty user application template
*
* Bare minimum empty user application template
*
* \par Content
*
* -# Include the ASF header files (through asf.h)
* -# "Insert system clock initialization code here" comment
* -# Minimal main function that starts with a call to board_init()
* -# "Insert application code here" comment
*
*/
/*
* Include header files for all drivers that have been imported from
* Atmel Software Framework (ASF).
*/
/*
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#include <asf.h>
#include "hardware.h"
void messysetup(void){
// kill the watchdog
WDT->WDT_MR = WDT_MR_WDDIS;
// start relevant peripheral clocks
PMC->PMC_PCER0 = 1 << ID_PIOA;
PMC->PMC_PCER0 = 1 << ID_PIOD;
}
int main (void)
{
sysclk_init();
// I think we can do 300, are at 150
board_init();
//NP1 (0)
// STLR PD12
// STLG PA3
// STLB PA2
messysetup();
np1stlr = pin_new(PIOA, PIO_PER_P11);
pin_output(&np1stlr);
np1stlg = pin_new(PIOD, PIO_PER_P21);
pin_output(&np1stlg);
np1stlb = pin_new(PIOD, PIO_PER_P20);
pin_output(&np1stlb);
while(1){
pin_set(&np1stlr);
pin_set(&np1stlg);
pin_set(&np1stlb);
delay_ms(100);
pin_clear(&np1stlr);
pin_clear(&np1stlg);
pin_clear(&np1stlb);
delay_ms(100);
}
}
\ No newline at end of file
/*
* pin.c
*
* Created: 11/23/2017 1:24:54 PM
* Author: Jake
*/
#include "pin.h"
#include <asf.h>
pin_t pin_new(Pio *port, uint32_t pin_bitmask){
pin_t pin;
pin.port = port;
pin.pin_bm = pin_bitmask;
return pin;
}
void pin_output(pin_t *pin){
pin->port->PIO_PER |= pin->pin_bm;
pin->port->PIO_OER = pin->pin_bm;
}
void pin_set(pin_t *pin){
pin->port->PIO_SODR = pin->pin_bm;
}
void pin_clear(pin_t *pin){
pin->port->PIO_CODR = pin->pin_bm;
}
void pin_toggle(pin_t *pin){
if(pin->port->PIO_ODSR & pin->pin_bm){
pin->port->PIO_CODR = pin->pin_bm;
} else {
pin->port->PIO_SODR = pin->pin_bm;
}
}
void pin_input(pin_t *pin){
pin->port->PIO_PER |= pin->pin_bm;
pin->port->PIO_ODR = pin->pin_bm;
}
int pin_read(pin_t *pin){
return pin->port->PIO_PDSR & pin->pin_bm;
}
\ No newline at end of file
/*
* pin.h
*
* Created: 11/23/2017 1:11:45 PM
* Author: Jake
*/
#ifndef PIN_H_
#define PIN_H_
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "ASF/sam/utils/cmsis/sams70/include/sams70n20.h"
typedef struct{
Pio *port;
uint32_t pin_bm;
}pin_t;
pin_t pin_new(Pio *port, uint32_t pin_bitmask);
void pin_output(pin_t *pin); // set as output
void pin_set(pin_t *pin);
void pin_clear(pin_t *pin);
void pin_toggle(pin_t *pin);
void pin_input(pin_t *pin);
int pin_read(pin_t *pin);
#endif /* PIN_H_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment